I have a Cypress test that uses stubbed responses with cy.intercept
. The requests that we're intercepting are polling an endpoint in our back end - we make one request per second until a status property in the response has changed.
I'm pretty new to Cypress so I might have the wrong idea about what you can actually test, but what I'd like to check is how often a request is made to this endpoint, i.e. assert that the polling is done at the correct rate (once/sec).
Is this possible to do with Cypress? Or should I perhaps look into some other tool?
This is how we're stubbing the network calls (simplified):
cy.intercept(
{
method: 'GET',
path: '/api/user',
},
{
body: {
id: '1',
status: 'UPDATED', // This is the status that eventually stops the polling
// etc.
},
}
).as('getUserUpdated');
cy.intercept(
{
method: 'GET',
path: '/api/user',
times: 2,
},
{
body: {
id: '1',
status: 'CREATED',
// etc.
},
}
).as('getUserCreated');