Before and beforeEach in supportFile - unexpected behavior during 'run all specs'
See original GitHub issueCurrent behavior:
before
and beforeEach
executed from support file seems unlogical.
As docs described, beforeEach
runs before each test in each spec file.
In this way, I expect to see before
hook before starting each spec file. But it doesn’t, it runs only once.
Desired behavior:
Seems like more clear to run before
hook before each spec file, like each before
hook from spec file does.
Steps to reproduce: (app code and test code)
I just pasted this piece of code into support/index.js
before(() => {
cy.log('Run before');
});
beforeEach(() => {
cy.log('Run before each');
});
Versions
Cypress: 3.3.1 MacOs: 10.14.5 Google Chrome: 75.0.3770.100
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Be careful when running all specs together - Gleb Bahmutov
Be careful when running all specs together. A common mistake when using beforeEach hooks in Cypress specs. Example application; Support file ...
Read more >How to run before on most cypress tests but not all
The official Cypress documentation on hooks has a great example showing where before and beforeEach hooks are placed in the describe and it ......
Read more >Writing and Organizing Tests - Cypress Documentation
You can define behaviors in a before or beforeEach within any of the cypress/support files: beforeEach(() => { cy.log('I run before every test...
Read more >2.2.1.8 - Setup and Teardown
These Triangle objects were all different, but what would happen if we needed to instantiate the same Triangle object for many tests?
Read more >Mocha - API Manual
Mocha tests run serially, allowing for flexible and accurate reporting, ... all tests in this block }); beforeEach(function() { // runs before each...
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
Oh, I see the issue now… sorry I didn’t realize there are two before defined by you. Sorry… please ignore whatever I said… I think you are right
you can also put before() and beforeeach() inside spec files…