I have install plugin cypress-file-upload
I have import this import cypress-file-upload in ./cypress/commands.js
const fileName = 'img112.jpg';
cy.fixture(fileName, 'base64').then(fileContent => {
cy.get('input[type="file"]').upload(
{ fileContent, fileName, mimeType: 'image/jpg' },
{ subjectType: 'input' },
);
});
Here is my HTML Code:
After that I am getting error like - TypeError: cy.get(...).upload is not a function
at my end
Node Version: v10.15.3
npm Version : 6.1.0
Cypress Version : 3.3.0
The .upload
command is not part of Cypress, you have to install a plugin to use it: https://github.com/abramenal/cypress-file-upload
Check out the README there for usage information.
I have the same problem, even after installing the extension and adding import 'cypress-file-upload';
to my commands.js file. Was anybody able to fix this?
Fixed: seems like the function is now called attachFile
instead of upload
Most helpful comment
I have the same problem, even after installing the extension and adding
import 'cypress-file-upload';
to my commands.js file. Was anybody able to fix this?Fixed: seems like the function is now called
attachFile
instead ofupload