Closed Mitchnsun closed 4 years ago
I may find something, in PapaParse they have this condition: if ((global.File && _input instanceof File) || _input instanceof Object)
(l.246) _input
is my file
in this case.
But in cypress my file
is not an instance of File nor Object, that's why it cannot parse it.
It seems that cypress-file-upload generate a file with a type object
not Object
or File
It is weird, this is what I got:
Object.create(file) instanceof Object -> false
Object.create({}) instanceof Object -> true
I create a repo to reproduce easily the issue: https://github.com/Mitchnsun/bug-cypress-csv-upload
I am not sure if the issue comes from cypress-file-upload or from Cypress and how they create a Blob/File.
Hi, thanks for submitting the issue!
Right now I am not able to take a look into the issue properly. In the meantime, I can suggest to check if the issue exist in v3 (previous major version): https://github.com/abramenal/cypress-file-upload/tree/v3.5.3 Sorry about that. Not sure I can provide ETA on solving this issue in v4 since I am the only one contributor and maintainer. If you have ideas on fixing that, please feel free to open Pull Request and we can review it together.
Thanks for understanding.
this is the same issue as https://github.com/abramenal/cypress-file-upload/issues/174, that can be fixed by: https://github.com/abramenal/cypress-file-upload/pull/184
Thanks @abramenal for your answer, I tried with the v3.5.2 and the issue doesn't exist on this version. Thanks @jdcl32 for the PR
I will work with the 3.5.2 until the @jdcl32 's PR will be merged
Hi @Mitchnsun can you please check that again in v4.0.5?
It works fine now with the v4.0.5 ! Thank you
For everyone who came here looking for solution, here's a workaround from https://github.com/cypress-io/cypress/issues/933#issuecomment-345554793
// nope
// this is using the global window in the test spec
new File()
cy.window().then((win) => {
// yup
// this is using the File constructor from the application window
new win.File()
})
I'm seeing this issue in Cypress v7.1.0
Still not sure how to fix it.. I can't change the internals of how papaparse work. Has anyone got this working with papaparse specifically?
Thanks!
Current behavior:
I tried to test the upload of a CSV file. Front side, I use CSV-file-validator to read and validate my file. But I have a parsing error (see below, cannot read stream of null) that I do not have outside of cypress. During cypress test, I can console.log
file
(see code below) and cannot see a difference between in cypress or in a real browser...I am not sure the issue is from cypress-file-upload library, but I only have this issue during testing with cypress (I create an issue on the repo of csv-file-validator).
Desired behavior:
CSV-file-validator could parse the file.
Steps to reproduce: (app code and test code)
Cypress:
cy.get('input[type=file]').attachFile('myfile.csv');
Front:Trace error:
Versions
Yarn: 1.12.3 Cypress: 4.3.0 Cypress-file-upload: 4.0.4 Csv-file-validator: 1.8.0 React: 16.6.0 MacOS: 10.14.6