A lot of our tests will share setup steps. Since Cypress is using Mocha under the hood, we can take advantage of existing features such as the ability to define a beforeEach
block that runs before each of our tests. In this lesson we’ll refactor two tests that contain duplicate commands by moving that duplication into the beforeEach
for our describe
block.
Can the beforeEach also be done outside the describe block?
Can the beforeEach also be done outside the describe block?
You can according to the Mocha docs, but I like to keep things grouped in the describe blocks.