Questions tagged [cypress-intercept]
111 questions
10
votes
3 answers
Test that an API call does NOT happen in Cypress
I've implemented API data caching in my app so that if data is already present it is not re-fetched.
I can intercept the initial fetch
cy.intercept('**/api/things').as('api');
cy.visit('/things')
cy.wait('@api') …

Blondie
- 160
- 9
6
votes
4 answers
Is there a possibility to test blocked network requests in Cypress?
We have multiple API requests on our page. When a call fails, certain behavior is expected. Is there a possibility of how to test a blocked network request in Cypress?

user3263975
- 63
- 2
- 5
4
votes
4 answers
4
votes
2 answers
capture websocket request in cypress
I'm trying to capture all the requests that occur during the test.
My application uses WebSocket and with the intercept command I can't catch wss requests.
Is there any way to do this?

Sergio Di Meglio
- 111
- 1
- 7
3
votes
2 answers
How to match multiple paths in cypress intercept?
Consider a page which allows you to select a vehicle like car, truck and bike. You can save the selection by pressing a Save button. The save button will trigger the appropriate api call depending on the type of vehicle you selected i.e. POST…

MasterJoe
- 2,103
- 5
- 32
- 58
3
votes
1 answer
Cypress intercept() fails when the network call has parameters with '/'
I need to add cy.wait() for some network call which has parameters having forward slashes in it.
eg: http://example.com/myPage1?id=598dccc6&startDate=10/01/2023&endDate=11/01/2023
For this, I've added the following…

art
- 1,358
- 1
- 10
- 24
3
votes
1 answer
How to intercept a specific URL with wildcards
I have an app, two different URLs are fetched. Part of the URL is a hash which needs wildcard pattern, and I want to capture just one URL in an intercept.
But the similarity of the string makes it difficult to get a pattern that…

Grainger
- 146
- 9
3
votes
4 answers
Cypress cy.wait() only waits for the first networkcall, need to wait for all calls
I would like to wait until the webpage is loaded with items. Each is getting retreived with a GET.
And I would like to wait on all these items until the page is loaded fully. I already made a interceptions for these. Named: 4ItemsInEditorStub
I have…

E. E. Ozkan
- 149
- 10
3
votes
1 answer
How to clear browser cache within a Cypress test
Background:
Hey all, I have a Cypress test I'm trying to write that should check whether an image URL has been called, after the image itself has been clicked on.
Currently I run the test and it finds the image URL on the first run but when it is…

devDan
- 45
- 1
- 5
3
votes
2 answers
How to wait for a request from a different URL in Cypress test?
In my Cypress test, I am trying to wait for a GET request & validate it's response. However, the test is timing out as the request never occurs.
Here is the request I am trying to wait for:
Here are some details around the test:
The URL of the app…

user9847788
- 2,135
- 5
- 31
- 79
3
votes
2 answers
cypress log request from interceptor
How can I log a "request.body" from cypress interceptor.
Here is the code
beforeEach(() => {
cy.log("---- -- Running beforeEach");
cy.intercept("POST", "/graphql", (req) => {
cy.log("-- --- -- loging from interceptor", req.body);
…

kevo
- 31
- 1
- 3
2
votes
1 answer
Unable to Override Cypress Intercept
I'm having a really hard time trying to override an existing Intercept handler in my Cypress tests. I was using Cypress version 5 but I'm in the process of updating it. I'm currently on version 7, trying to get my tests to work before updating to…

Ricardo
- 43
- 5
2
votes
1 answer
Create custom command in Cypress containing asserting / chain commands
I wish to create a custom command that contains status code assertions:
cy.wait('@interceptedEndpoint')
.its('response.statusCode')
.should('eq', 200)
the last two lines are what I want inside the custom…

KiritoLyn
- 626
- 1
- 10
- 26
2
votes
1 answer
How to make Cypress test fail if it makes a request that does not have an intercept associated with it?
How to make Cypress test fail if it makes a request that does not have an intercept associated with it?
Let's say cypress navigates to a page and makes 10 requests. How can I make cypress automatically fail if any of those requests are not…

mcool
- 457
- 4
- 29
2
votes
1 answer
Assert/check polling rate for stubbed requests in Cypress test
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…

Ellen
- 110
- 7