I have a form that accepts a file and using cypress-file-upload
, I made it to work correctly. But I also have a scenario where I need to verify an error when no file is uploaded. The package itself is validating the file is exist or not. How we can test in such case?
cy.get('input[type="file"]').attachFile();// Cannot read property 'filePath' of undefined
cy.get('input[type="file"]').attachFile(""); //missing "filePath" or "fileName".
Please make sure you are passing either "filePath" or "fileName"
cy.get('input[type="file"]').attachFile("expense1.json")//Works for the positive case
cy.get(".alert").should('be.visible').and('contain', "You poor guy did not upload a file...")