Closed Mitchnsun closed 4 years ago
Hi @Mitchnsun
Can you please check if you have a File in onFileUploaded
method before call CSVFileValidator
@Mitchnsun papaparse has been upgraded. You can get the latest version 1.8.0
Hi @shystruk, thanks for your answer.
I upgraded to 1.8.0 but unfortunately still have the issue.
Here is what I have before calling CSVFileValidator
method :
Pretty much the same in browser when it works smoothly.
hm, the validator should work in this case. Waite for the cypress-file-upload response. Can you please create an example repo or send a demo code.
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 instanceof File, that's why it cannot parse it. I transfer this comment to cypress-file-upload.
Good point. This may be the issue. Check on cypress-file-upload what instance of File they return and probably you can make it the File instance before you pass it to the validator.
They return an object
not an Object
. You can reproduce the bug with this repo: 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.
I'll keep you updated
As an idea try to get the file content from the object which cypress returns and create a File instance and pass it to the validator.
closed the bug as it is not related to the validator
Thanks for your help, the issue was fixed by v4.0.5 of cypress-upload-file
Current behavior:
I tried to test my code with cypress and cypress-upload-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 csv-file-validator library, but I only have this issue during testing with cypress (I create an issue on the repo of cypress-file-upload). Maybe the library waiting for something that the test do not provide.
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