Cypress and Intercepting XHR Responses
Here is an example:
import '../support/cognito';
describe('Access Account Page', function () {
beforeEach(function () {
cy.intercept({
method: 'GET',
url: '/dev/subscription/invoice',
}).as('invoice');
// Programmatically login via Amazon Cognito API
cy.loginByCognitoApi(
Cypress.env('cognito_username'),
Cypress.env('cognito_password'),
);
});
it('Access the account page', function () {
cy.contains('h1', 'Account');
cy.wait('@invoice').its('response.statusCode').should('eq', 200)
});
});
It expects the api call to return 200
See my other article to get more details about Cognito, amplify and Cypress: Cypress, Amplify & VueJS