abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

[Feature] Uploading files with invalid syntax (Such as broken .json file) for testing web application behavior #323

Closed TiManGames closed 2 years ago

TiManGames commented 2 years ago

Consider the following .json file:

{
    "name": , {
.,
}

I have a web app that accepts files, if the user decides to upload a broken .json file, an error message appears. I want to test that scenario, and so I wanted to upload this file using cypress-file-upload.

However, it seems I can't do that, this is the result I get:

image

I would like to have an option to ignore or skip file validation and just upload it as it is.

My code is cy.get('ngx-dropzone') .attachFile(${fileName}, {subjectType: 'drag-n-drop'});

I'm using Cypress 8.1.0, Chrome 92 on Windows 10

abramenal commented 2 years ago

Hi @TiManGames Thanks for submitting the issue. I think in this case you have to specify encoding: 'utf-8' so cypress won't try to parse it. Can you please try something like this and let me know about the results

cy.get('ngx-dropzone') .attachFile({ filePath: fileName, encoding: 'utf-8' }, {subjectType: 'drag-n-drop'});
abramenal commented 2 years ago

Feel free to reopen this if you think there is an issue with what I explained earlier