Closed cdlans closed 1 year ago
Hi @cdlans. Thank you for opening an issue. Would you be able to provide a working reproduction repository for us to see what is going on? I am wondering if we are mistakingly injecting into this file.
Unfortunately we have to close this issue due to inactivity. Please comment if there is new information to provide concerning the original issue and we can reopen.
Current behavior
When running an e2e test which downloads a file and then asserts the file exists using
cy.readFile(filename).should('exist')
the test fails with "Unexpected end of JSON input".This seems to be due to Cypress reading the file partially, before it has been downloaded completely. If I add a
cy.wait(500)
between the download and the assertion, then the test passes.Alternatively I can use
cy.readFile(filename, null).should('exist')
so Cypress is not trying to parse the file contents. Interestingly usingcy.readFile(filename, 'binary').should('exist')
did not solve the error.Desired behavior
readFile()
should retry reading the file, if it encounters an "Unexpected end of JSON input".Test code to reproduce
Cypress Version
12.8.1
Node version
18.14.0
Operating System
macOS 13.3.1
Debug Logs