Cypress · Junior · Question 40 of 75

Where should code that runs before each test, like cy.visit('/'), go?

Show the answer

Correct answer: In beforeEach

Explanation

beforeEach runs before every test. Code outside hooks and tests runs while specs are collected, not inside a test.

Further reading

Problem with a question

Cypress · Junior · question 40

Test yourself

Take the Cypress · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz