Become a member
to unlock all features

    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