-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Values created as part of tests using cy.write are not taken by Cypress if we add {watchForFileChanges: false} in Cypres.json #22410
Comments
@chaitanyarajugithub thank you for the report. Reading over your issue, I figured I knew why this was happening, and that we were detecting fixture changes as spec file changes incorrectly. I built a simple test case to verify, but as it turns out I don't see the same behavior that you are reporting. describe('dynamic fixture testing', () => {
let val1
let val2
beforeEach(() => {
val1 = Math.random()
val2 = Math.random()
cy.writeFile('cypress/fixtures/data/simulator.json', { val1, val2 })
})
for (let i of Array(10)) {
it('asserts fixture data', () => {
cy.readFile('cypress/fixtures/data/simulator.json').then((file) => {
expect(file.val1).to.eq(val1)
expect(file.val2).to.eq(val2)
})
})
}
}) The above spec in my environment generates 10 sets of unique data, one for each Try giving the above test a shot in your project; if it triggers a loop, there's something else impacting this behavior. Providing your OS/version and your cypress config file would also help us investigate more granularly. |
Unfortunately we have to close this issue due to inactivity. Right now there doesn't seem to be enough information to reproduce the problem on our end. We'll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward. Please open a new issue with a reproducible example and link to this issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide. |
Current behavior
As part of the tests, I am creating a test data JSON file in the features folder.
What I am trying to do is, I am creating test data and using it as part of tests and validating output data with created data.
In cypress without adding these commands
watchForFileChanges: false
in cypress.json, the tests keep looping as there is a file change.With adding the command watchForFileChanges: false in cypress.json it is not taking the latest created values of the file. it is taking old values.
Desired behavior
The file changes are values created as part of tests using cy.write should be able to get the latest values in tests. if we not adding {watchForFileChanges: false} is there any way to stop the re-run of tests for file changes.
Test code to reproduce
Test file:
`describe('Balance Measurement', () => {
beforeEach(() => {
cy.writeFile('cypress/fixtures/data/simulator.json', { "SAMPLEID": faker.random.alphaNumeric(5), "METHODSPECIES": faker.random.alpha(5), "STUDYNO": faker.random.numeric(8), "ANIMALID": faker.random.numeric(4) })
})
});
File created:
{"SAMPLEID": "blisp",
"METHODSPECIES": "ofiik",
"STUDYNO": "90077968",
"ANIMALID": "1314"
}
ADDED below code in cypress.json
{watchForFileChanges: false}`Cypress Version
"cypress": "^9.5.1"
Other
No response
The text was updated successfully, but these errors were encountered: