Multiple files, multiple beforeEach, not all run
See original GitHub issueHello,
Current behavior:
I have 2 test files, both have their beforeEach
with some commands that stub xhr requests.
However, only one of the 2 beforeEach
sections gets run. I do see it in the “Routes” section, but with 0 hits.
When I run both files in isolation, they work as expected.
Example command:
Cypress.Commands.add('mockGetActivationsData', (fixture = 'getActivations.json') => {
cy.server();
cy.route('GET', '**/**/business-units/*/activations', `fixture:activations/${fixture}`);
});
Desired behavior:
Each beforeEach
section should allow commands to be fired to intercept xhr requests.
Steps to reproduce:
Create 2 test files. Each of them have a beforeEach
section that call a command, that stubs a XHR request.
It works fine when I remove my command calls from every beforeEach
section and duplicate them across every test.
Versions
- cypress
2.1.0
- chrome
66
Thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (11 by maintainers)
Top Results From Across the Web
Sinon with multiple mocha test files - node.js
BefireEach must not call twice for one mocha test. Does importing multiple files call beforeEach twice? Can someone suggest any possible ...
Read more >Writing and Organizing Tests
You can write placeholder tests in several ways as shown below, and Cypress knows NOT to run them. Cypress marks all the tests...
Read more >Jest's 'beforeEach' may not be running the way you think it ...
So while I was expecting the top-beforeEach to have run 3 times total, once for each method within its block, it actually runs...
Read more >Mocha seems to reuse required modules in multiple files. ...
Mocha running with multiple files seems not to cleanup after one file is done. Required modules are not reinitialised, but reused.
Read more >JUnit 5 User Guide
Unlike previous versions of JUnit, JUnit 5 is composed of several different ... Unlike JUnit 4's @Test annotation, this annotation does not ......
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 FreeTop 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
Top GitHub Comments
@zeralight Can you provide an example we can run completely? There’s a lot of things not included in your example that may be affecting the way it runs. You can edit our tests against our example.cypress.io website, which has some routing. Repo to fork: https://github.com/cypress-io/cypress-example-kitchensink
And opening a new issue would probably be best than this older issue.
I am having a similar issue where the root describe isn’t running with nesting describes In some test, I delay a network request to test a loading state.
When I uncomment the line // cy.wait(‘@requestFoo’), the issue disappears. Cypress: 5.3.0