Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding null as an encoding argument to cy.readFile command results in TypeError #20683

Closed
Zaista opened this issue Mar 18, 2022 · 3 comments · Fixed by #20689
Closed

Adding null as an encoding argument to cy.readFile command results in TypeError #20683

Zaista opened this issue Mar 18, 2022 · 3 comments · Fixed by #20689

Comments

@Zaista
Copy link

Zaista commented Mar 18, 2022

Current behavior

Adding null as an encoding argument to cy.readFile command results in TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.

It seems that null option somehow bypasses the timeout and waiting for file to be downloaded, because as soon as I add 1 sec wait, the command works as expected, and file is read.

Desired behavior

cy.readFile command (with null as encoding argument) should fall back to default timeout of 4 seconds and retry until file is found.

Test code to reproduce

... trigger a download of a file

cy.readFile(pathToFile, null);

Cypress Version

9.5.1

Other

No response

@emilyrohrbough
Copy link
Member

@Zaista Thank you for reporting this issues. I was able to reproduce this with this simple example:

it('test', () => {
  cy.readFile('./cypress/fixtures/non-existent-file.json', null)
})

Looking in the code, this appears to be a relatively straight forward fix.

@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Mar 18, 2022
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Mar 21, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 21, 2022

The code for this is done in cypress-io/cypress#20689, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 28, 2022

Released in 9.5.3.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.5.3, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants