Following the documentation on how to use Blobs with Cypress we have arrived at the following piece of code:
.fixture('upload_teachers.csv').as('teachers')
.get('input[type="file"]').then(function($input) {
Cypress.Blob.binaryStringToBlob(this.teachers).then(function(blob){
$input.fileupload('add', { files: blob });
});
})
However we keep running into the same error:
Uncaught (in promise) TypeError: $input.fileupload is not a function
Running CLI v0.12.0 and App v0.18.5.
Would appreciate any help!
Currently, the documentation expects that you use the jQuery File Upload plugin. The fileupload function comes from this plugin.
Sorry this was not made very clear in the documentation. We do plan to handle file uploads in a better way in the future, but this is the best workaround to test them for now.
There is already an open issue: https://github.com/cypress-io/cypress/issues/170
Will leave this here in case it helps somebody
https://github.com/javieraviles/cypress-upload-file-post-form
It would be helpful if the Cypress Blob documentation liked the jQuery File Upload plugin instead of just saying "jQuery File Upload plugin" which is ambiguous.
If you want to open an issue on our documentation, you can open it here.
Most helpful comment
Currently, the documentation expects that you use the jQuery File Upload plugin. The
fileuploadfunction comes from this plugin.Sorry this was not made very clear in the documentation. We do plan to handle file uploads in a better way in the future, but this is the best workaround to test them for now.