Hey! I'm having issues setting thing sup like you did on the examples.
I have a simple input with the id #file_upload_start
cy.fixture('image1.jpg', 'base64').then(fileContent => {
cy.get('#file_upload_start').upload(
{ fileContent, fileName: 'image1.jpg', mimeType: 'image/jpeg' },
{ subjectType: 'input' }
)
cy.get('#fileList tr[data-file="image1.jpg"]').should('contain', 'image1.jpg')
})
The image exists in the fixtures directory.
I also tried without the base64, it also fails.
1 issue I encountered
1) Open images in viewer "before all" hook for "See image.jpg in the list":
TypeError: Path must be a string. Received { fileContent: '/9j/4AAQSkZJRgABAQEASABIAAD/....',
fileName: 'image1.jpg',
mimeType: 'mime/jpeg' }
Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Open images in viewer'
at assertPath (path.js:28:11)
at Object.join (path.js:1232:7)
at Object.get (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/fixture.js:45:16)
at backendRequest (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/socket.js:290:34)
at tryCatcher (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
at Function.Promise.attempt.Promise.try (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
at Socket.<anonymous> (/root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/server/lib/socket.js:303:34)
at emitMany (events.js:146:13)
at Socket.emit (events.js:223:7)
at /root/.cache/Cypress/3.2.0/Cypress/resources/app/packages/socket/node_modules/socket.io/lib/socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
@skjnldsv thanks for submitting the issue!
Can you please bring more details on your setup so we can look into it together? Especially your package.json, cypress/support/index.js and cypress/support/commands.js
For the first look it seems you have some other command bound to cy.upload. I even looked into cypress release notes whether they released a new feature called like that 馃槃 The answer is no.
So let's try to fix that together.
@abramenal Ah,I'm an idiot, I indeed created an upload command, so it might be that :woman_facepalming:
I assumed there was a difference between a command bound to cy and one bound to cy.get(xxx). I'll try to change that and report back ! :grin:
Thanks for your help!!
// Import commands.js using ES2015 syntax:
import './commands'
Cypress.Commands.add('upload', (fileName, mimeType) => {
cy.visit('/apps/files')
cy.fixture(fileName, 'base64').then(fileContent => {
cy.get('#file_upload_start').upload(
{ fileContent, fileName, mimeType },
{ subjectType: 'input' }
)
})
})
That was it! :)
It works fine now!
I changed my function name.
Thanks for your time and your awesome plugin! :tada: :rocket:
@skjnldsv no worries, that happens 馃槃
Thanks for participating!
@allcontributors[bot] add @skjnldsv for question
@abramenal
I've put up a pull request to add @skjnldsv! :tada: