Cypress · Junior · Question 31 of 75

How do you stub an API response with fixed data?

Show the answer

Correct answer: cy.intercept('GET', '/api/users', { fixture: 'users.json' })

Explanation

A static response or fixture replaces the real server answer, making tests fast and deterministic.

Further reading

Problem with a question

Cypress · Junior · question 31

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