Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intercept doesn't work in beforeEach #29405

Open
lalicia opened this issue Jul 10, 2023 · 1 comment
Open

Intercept doesn't work in beforeEach #29405

lalicia opened this issue Jul 10, 2023 · 1 comment
Labels
stage: needs investigating Someone from Cypress needs to look at this

Comments

@lalicia
Copy link

lalicia commented Jul 10, 2023

I originally posted under this issue where someone had detailed the problem I was having in a different Cypress repository - I was advised to move the post to here by @nagash77.

The issue is NOT in this repository - it's in an archived repository https://github.com/cypress-io/cypress-realworld-testing-blog

The code given in cypress/e2e/practice/network-request.cy.js is:

describe("Network Requests", () => {
  beforeEach(() => {
    cy.intercept("GET", "http://localhost:3000/api/posts", (req) => {
      // this is to disable browser caching
      // https://glebbahmutov.com/blog/cypress-intercept-problems/
      delete req.headers["if-none-match"];
    }).as("posts");

    cy.visit("http://localhost:3000");
  });

The error is:
image

Can someone please explain why this is happening and how to fix it? I'm new to Cypress and trying to learn. Thanks :)

@sperrye
Copy link

sperrye commented Oct 14, 2023

I'm also experiencing this issue after upgrading from 12 to 13.
The intercept aliased in the beforeEach was working reliably until the upgrade.

@jennifer-shehane jennifer-shehane transferred this issue from cypress-io/cypress-realworld-app Apr 25, 2024
@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

4 participants