cypress: cy.writeFiles runs into errors

Current behavior

Hello, while integrating Cypress version 12.15.0 some of our tests failed with PayloadTooLargeError: request entity too large. The problematic test cases write files around 200 - 300 kb. Cypress UI shows the error message cy.writeFile() must only be invoked from the spec or support file

Desired behavior

On Cypress 12.14.0 the same tests ran fine.

Test code to reproduce

https://github.com/JanUrb/cypress-test-writefiles-error

Cypress Version

12.15.0

Node version

v20.3.0

Operating System

macOS 13.3.1

Debug Logs

No response

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 7
  • Comments: 21 (10 by maintainers)

Most upvoted comments

Same error, but with cy.readFile() after updating to 12.15.0

cy.readFile() must only be invoked from the spec file or support file.

@bimanpathirage

Can I please know the way to downgrade the version? TIA

If you are using npm, then simply

npm install cypress@12.14.0 --save-dev --exact

For Yarn

yarn add cypress@12.14.0 --dev --exact

This is still not resolved, as we are also getting the same error:

ss

The bespoke code resides in a custom class, which implements the cy.writeFile() function like so:

cy.writeFile('cypress/support/data/paymentOrders/groupOrders.json', data);

Is there a workaround for this, or is downgrading to 12.14.0 the only option?