Questions tagged [cypress-intercept]
111 questions
2
votes
3 answers
How to get cypress to dynamically update a fixture to a graphql call
I need to mutate a graphql call in Cypress to where I can change certain key:value pairs within a fixture depending on the test.
I know I can call a graphql fixture with a format similar to this:
cy.intercept('POST', '/graphql', (req) => {
if…

Pix81
- 585
- 3
- 15
- 33
2
votes
2 answers
How to capture the 'latest' instance of a request if it is called multiple times during a Cypress test?
In my Cypress Cucumber test, here is my current feature file scenario (this scenario fails on the final step):
Given I log in
Then I am on the dashboard
And the dashboard displays 0 peers (@Peers is called here, & 0 is the correct value here)
When I…

user9847788
- 2,135
- 5
- 31
- 79
2
votes
3 answers
Cypress - Visiting two different websites and storing value in variable
I'm new to Cypress, I need in the same test, visit two different URLs and store a value from the first one, to use in the second.
I need to visit this website: https://consulta.guru/gerador-cnpj-gratis
click on "Gerar" and copy the generated value…
2
votes
2 answers
Cypress sharing data (alias) between spec files
I need to use an alias I got after intercepting a cy.wait(@..) in other tests (in different files), but I am not sure how I could do it.
However, seems like it is possible if save the data in plugins/config space and then fetch using cy.task But I…

Fah
- 207
- 3
- 16
2
votes
1 answer
How to make cypress wait for a response that depends on another response?
From response A (/list.json) my app receives a list of items. Based on the output of A, my app makes another set of requests B for individual items (/one.txt, /two.txt, ...).
Now in my test I want to make sure that all responses B return HTTP…

gicig
- 334
- 3
- 14
2
votes
1 answer
Is there a way to intercept multiple requests linked by an "OR" conditional operator?
I am a beginner with cypress. I've been looking for a way to intercept API calls to at least one of multiple URLs.
Let's say a button is clicked and something like this code is executed to check if a list of requests were called…

ElVincitore
- 355
- 2
- 12
2
votes
2 answers
Cypress adding token to all requests headers
I'm testing a website that returns token in body from login request. Then all the requests made after we logged in use this token value in header.
I made a custom cypress command that logs in by sending a POST request, but i can't get how to make it…

Yaroslav Fomin
- 33
- 4
2
votes
1 answer
What do the dollar-sign ( $ ) do before variables in Cypress (in then clauses)
In the Cypress documentation for Variables and Aliases it uses the dollar sign before the variables in the then-clauses. Like this:
cy.get('button').then(($btn) => {
// $btn is the object that the previous
// command yielded us
})
But I can't…

Zeth
- 2,273
- 4
- 43
- 91
2
votes
1 answer
How to ignore certain fetch requests in cypress cy.visit
When calling cy.visit("https://my-page.com") my page will fetch a number of external libraries/scripts. One of them is for sentry.io. Sometimes this particular fetch will just hang forever. The website is perfectly usable without it. Is there a way…

Daniel Gruszczyk
- 5,379
- 8
- 47
- 86
2
votes
1 answer
How to freeze request to test that components are disabled using Cypress?
I'm using VueJS and Cypress to test the app e2e. I have a modal where user fills a form and click on the "send" button. When user clicks on that button, we disable the form fields and the button so the user won't be able to fill/click them. After…

vesii
- 2,760
- 4
- 25
- 71
1
vote
1 answer
Cypress test misses redirect/XHR GET despite interceptor
I'm testing a form in a Laravel/Vue/Inertia application that can select from a list of users. The form adds a new user (an XHR post) to the database. The Laravel controller then redirects back to the form (an XHR GET). The form's user menu now…

buckthorn
- 1,727
- 13
- 15
1
vote
0 answers
Cypress graphql request is failing with large payload
In the code I am calling the GraphQL API with a request having the parameter fields as an array of 21 objects along with an image.
If fields has 15 objects, the GraphQL API request goes through fine. But, if it is more than that (15 objects), then…

user521024
- 521
- 2
- 7
- 29
1
vote
1 answer
Is there a convenient way to update stubbed API calls when the app is updated to expect a new JSON format?
Our app is under heavy development, and our API JSON formats are constantly changing. Here's a simplified example:
{
"succeeded": true,
"message": null,
"data": {
"purchaseOrderId": "1f7968e2-f18e-417b-9e7b-1c35e5bdd465",
…

chris6owens
- 11
- 3
1
vote
2 answers
Cannot set file type of fixtures in Cypress reply intercepts
I'm trying to stub a midi file in a Cypress intercept. From the URL I am deriving a fixture to load and use in the reply. I am doing something like:
cy.intercept("**/MIDI/*", (req) => {
const fixtureName = get_last_part_of(req.url) // This will…

Bradley Schmerl
- 11
- 2
1
vote
0 answers
How do I handle AuthO popup with Cypress
I am writing e2e tests with cypress for an app that uses auth0 for aunthentication
from the documentation cypress 12 supports this using the cy.origin command .. my issue is when I click the login button, the origin command does not point to my new…

cjmash
- 173
- 1
- 2
- 10