Add a beforeEach function to cypress tests to avoid copying and pasting needless code

Share this video with your friends

Send Tweet

DRY (Don't Repeat Yourself) is (in most cases) a good idea when it comes to programming.

E2E tests are no different - if we have actions that we want to perform before every cypress test, it would be great to define them in a single spot.

In this lesson we're going to learn how to use beforeEach command in order to visit the app homepage before every test in a suite.