Cypress · Middle · Question 40 of 77
What is the difference between before and beforeEach?
- 1
beforeruns once per block,beforeEachbefore every test - 2They are the same; one is an old name for the other
- 3
beforeruns in Node,beforeEachin the browser
Show the answer
Correct answer: before runs once per block, beforeEach before every test
Explanation
With test isolation, state from before is cleared before each test, so per-test setup usually belongs in beforeEach.