-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
Current behavior
When trying to intercept a request, if the request is already cached locally the intercept method is unable to intercept the query. Workarounds for caching previously mentioned deleting various headers that determine whether the server returns cached data or not, do not work as it doesn't intercept the query at all.
If I disabled caching via the console's network tab, the query works every time and I'm able to wait for it to complete.
Desired behavior
If the data is cached locally, return the local response. If the intended behavior of Cypress is to mimic a user's experience, then we should not have to append query parameters to get a fresh set of data each time a query is presented.
Test code to reproduce
it('successfully loads', () => {
cy.visit('/');
cy.intercept('GET', `${projectServicesAPI}/projects/search**`, (req) => {
delete req.headers.Authorization;
}).as('projects');
// Ensure that the projects are loaded
cy.wait('@projects').its('response').should('deep.include', {
statusCode: 200
});
});
The response from the API sends the following cache control header:
cache-control: private, max-age=600
Versions
Cypress Version: 6.2.1
Browser: Electron 87
OS: Mac