[Vuejs]-Cypress Spying on Vue components

0👍

To spy over a response, you can use the route command instead of spy.
https://docs.cypress.io/api/commands/route.html

it('Example Test', function () {
    cy.visit('https://stackoverflow.com/');
    cy.server(); // cy.server needs to be invoked first in order to use cy.route command
    cy.route({
        url: `**/your/request/path/**`,
        method: 'POST',
        onResponse: (xhr) => {
            console.log(xhr);
            // here you can assert on xhr.response.body values
        }
    });
});

Leave a comment