-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
cy.writeFiles runs into errors #27097
Comments
I encounter exactly the same issue when bumping to 12.15.0 on Node 18. |
Same error with version 12.15.0 (working fine with 12.14.0) but a different origin, probably related to the size of the snapshot file:
|
Same error, but with cy.readFile() after updating to 12.15.0
|
We're aware of the "must only be invoked from the spec file or support file" issue and are looking into it now. Until a fix is identified, tested, and released you can temporarily downgrade to Cypress v12.14.0 which does not exhibit this issue. |
This is a duplicate of #27099 which has a slightly more targeted description of the issue so I will close this in favor of that one |
Cypress v12.16.0 has just been released with a fix for the issue with cy.task, apologies for the oversight on that bug. Thanks for using Cypress, everyone! |
This is still not resolved, as we are also getting the same error: The bespoke code resides in a custom class, which implements the
Is there a workaround for this, or is downgrading to 12.14.0 the only option? |
Hi @bdimitrovski , sorry you're still having issues. We addressed an issue that was causing this error in 12.16.0 but it appears you've identified one or more edge cases we missed. Are you able to share a reproduction case we can use to troubleshoot? |
Hi @mike-plummer , Thanks for the quick reply. Here's the repro code https://github.com/bdimitrovski/writefile-cy-issue, however, when I used the exact same function as in my real project, I could not get it to fail, it normally populates the file using Is there anything else I could be missing? |
Still able to reproduce #27099 via |
@elGatoMantocko Thanks for the report. That will be helpful for debugging. |
@bdimitrovski It's tricky to say, since that's the information we'd be trying to use the reproduction to suss out. It could be something different with how the project is structured, as in which file the function that calls There's two known issues that cause this error right now (and are in the process of being fixed), so I would first check to see if your project code is encountering it because of one of these:
function writeFile (options) {
cy.writeFile('file.txt', 'contents', options)
}
writeFile() |
I have the same issue - only showing up in headless mode
inside of the spec file |
@chrisbreiding thanks for looking into this - here' a part of my const { defineConfig } = require('cypress');
const fs = require('fs-extra');
const path = require('path');
function getConfigurationByFile(file) {
const pathToConfigFile = path.resolve('..', 'cypress/cypress/config', `${file}.config.json`);
return fs.readJson(pathToConfigFile);
}
module.exports = defineConfig({
reporter: 'cypress-multi-reporters',
reporterOptions: {
configFile: 'reporter-config.json'
},
e2e: {
responseTimeout: 30000,
requestTimeout: 30000,
viewportWidth: 1440,
viewportHeight: 900,
baseUrl: "http://localhost:8080/",
supportFile: "cypress/support/e2e.js",
video: false,
trashAssetsBeforeRuns: true,
env: {
username: "**********",
password: "**********",
apiBaseUrl: "**********",
docsUrl: "**********"
},
specPattern: "cypress/e2e/**/*.spec.ts",
setupNodeEvents(on, config) {
const loggerOptions = {
outputRoot: `${config.projectRoot}/cypress/reports/logs`,
outputTarget: {
'verbose.log': 'txt',
'verbose.json': 'json'
}
}
require('cypress-mochawesome-reporter/plugin')(on);
require('cypress-terminal-report/src/installLogsPrinter')(on, loggerOptions);
on('task', {
getDownload: () => {
const downloadsFolder = config['downloadsFolder'];
if (!fs.existsSync(downloadsFolder)) {
fs.mkdirSync(downloadsFolder);
}
return new Promise((resolve, reject) => {
const watcher = fs.watch(downloadsFolder, (eventType, filename) => {
if (eventType === 'rename' && !filename.endsWith('.crdownload') && !filename.endsWith('.part')) {
resolve(filename);
watcher.close();
}
});
setTimeout(reject, config.taskTimeout);
});
}
});
const file = config.env.configFile || 'dev';
return getConfigurationByFile(file);
},
},
}); I do not see anything outstanding here that could cause issues with |
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 |
Reproducible example (still fails with 12.17.0) in bahmutov/cypress-examples#174
|
Thanks for the repro, @bahmutov! That's a new edge case and being able to reproduce it will help a lot in debugging it. |
Released in This comment thread has been locked. If you are still experiencing this issue after upgrading to |
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 messagecy.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
The text was updated successfully, but these errors were encountered: