Skip to content

Intercept does not return locally cached data and times out #14459

Description

@asithade

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.

Screen Shot 2021-01-07 at 5 07 28 PM

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions