question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intercept does not work between tests (`it`)

See original GitHub issue

Current behavior

We intercept every request call that goes out of cypress to add an AUTH header to every request. When the header is not attached we get network requests that fail. Before when using Cypress 6.8, all requests were intercepted even between tests (it). Now that is not the case anymore. This causes our tests to flake very frequently.

Desired behavior

Intercept all requests!

Test code to reproduce

You can reproduce the errors pretty consistently with the repo: https://github.com/giacaglia/cypress-test-tiny

You need to run both the frontend and the backend to test it out.

Cypress Version

8.3.1

Other

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:5
  • Comments:8

github_iconTop GitHub Comments

4reactions
ismyrnowcommented, Sep 15, 2022

I can confirm that I’m still seeing this behavior in cypress v10.6.

My use case is defining intercepts in a beforeEach hook. It appears that a test can complete, yet the page can still trigger a network request while the next test’s beforeEach hook is running (which is prior to those network request intercepts being defined).

In other words:

  1. Test1 a. beforeEach: define some intercepts b. run the test c. test passes
  2. Test2 a. beforeEach: define some intercepts… FAILURE! Network requests triggered from Test1 are showing up in the beforeEach step, prior to intercepts getting defined!
2reactions
giacagliacommented, Sep 22, 2021

Would love any updates on this issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress cy.intercept Problems - Gleb Bahmutov
We have completely separated the suite of tests that should all start with zero items from the suite of tests that should start...
Read more >
in cypress, intercept in test doesn't work - Stack Overflow
Since it works when the intercept is moved up in the command order, it seems that cy.waitLoading() triggers the POST and not ......
Read more >
A Practical Guide to Intercepting Network Requests in Cypress
In our following test we are facing a weird situation. Let's first look at the code and then at the video from test...
Read more >
intercept - Cypress Documentation
All intercepts are automatically cleared before every test. Syntax. // spying only cy.intercept(url) cy ...
Read more >
Network Requests with Cypress by Cecelia Martinez - GitNation
So this image is from a presentation called how cy.intercept works, my glove bomb top. And essentially, you can see in the image...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found