Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Mock Your Backend with Cypress


    Using cy.server, cy.route, and cy.wait, we can intercept requests to our real backend, and return known mock responses.

    The pros of using this approach:

    • It's much faster than interacting with the real backend
    • Doesn't need to seed data to the backend
    • Easy control of requests and responses
    • Can mock network delay and failure


    • No guarantee the stubs match the real backend responses
    • Not full end-to-end testing

    Recommended Homework:

    • Mock the route to create a new todo, and reply with a 200
    • Mock the route to edit an existing todo, and reply with a 200