Cypress.env() state is not reset on rerun of test
See original GitHub issueCurrent behavior:
Cypress.env()
state is only read in once when the runner starts. This causes any changes to Cypress.env()
to not reset when you rerun a test.
Desired behavior:
Clean, fresh Cypress.env()
for each rerun of a test.
Steps to reproduce: (app code and test code)
{
"env": {
"num": 2
}
}
it('should set ENV var num', () => {
cy.log(`${Cypress.env('num')}`) // logs 2, but 3 on rerun
Cypress.env('num', 3)
cy.log(`${Cypress.env('num')}`) // logs 3
})

But if I rerun the test, the log is already 3 at the beginning.

Versions
3.8.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Test Retries - Cypress Documentation
If the test fails a third time, Cypress will mark the test as failed and then move on to run any remaining tests....
Read more >Run Just The Failed Tests In Cypress - Gleb Bahmutov
Then I reset the failed tests filter by running the Cypress.grep() from the console, and Cypress starts running all tests again.
Read more >reset cypress config on rerunning tests - Stack Overflow
I have the problem. when i pass body instead of fixture in the interceptor , cypress forces the header to application/json . no...
Read more >Configuring Vitest
To configure vitest itself, add test property in your Vite config. ... setup return { teardown() { // called after all tests with...
Read more >End-to-end tests with Cypress - Metabase
You can also call restore() inside beforeEach() to reset before every test, or inside specific tests. Snapshots are created with a separate set...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
yes . still this issue persists in 9.2 version
Nice writeup, I’m hitting the same issue, with both
Cypress.config
andCypress.env
. This is still occuring incypress@4.4.1
.The docs state that both
env
andconfig
resets between both runs and test suites, neither of which is currently true.