Questions tagged [cy.intercept]

13 questions
3
votes
3 answers

Cypress intercept blocks the request when it's called several times in a test run

I've created some tests in Cypress to add and duplicate article in our Angular application. The code for test ArticlesTest.js describe('Shop articles single station', () => { const productManagementPage = new ProductManagementPage() const…
hubesal
  • 141
  • 3
  • 13
3
votes
1 answer

Cypress intercept - execute same api multiple times with different payload in same test case

I want to execute the multiple times same API with different payloads, but it's not working. it('call same api with different payload',()=>{ cy.intercept('PATCH', `**/user/1`,{name:'thava'} ).as("action1") cy.intercept('PATCH',…
Thavaprakash Swaminathan
  • 6,226
  • 2
  • 30
  • 31
2
votes
1 answer

Cypress: how to test routes status code throughout entire test?

I have a test where a certain fetch request is happening around 70 times and at the end of the test I need to check that all the status codes were 200 or 204. So far I am intercepting the request and can check the response.statusCode for that 1…
1
vote
1 answer

How to prevent making multiple .json files in the fixture folder while using cy.intercep for the same endpoint with Cypress Javascript

At this point I am stubbing API endpoints with Cypress Intercept. It is working great, but I've the feeling I could use it more efficient. Currently I have the following test: cy.intercept('GET', '**/Classifications', { fixture:…
E. E. Ozkan
  • 149
  • 10
1
vote
1 answer

Cypress intercept registering too late after button click

And thank you in advance! I am working on some cypress E2E tests, and having some issues with the intercept. I have a button that upon click, shall send a PUT request to the backend to change the status of a user, for which I have written the test…
nahsiloh
  • 21
  • 1
  • 4
1
vote
1 answer

cypress intercept not overriding cypress alias

I'm doing some testing and I intercept some api calls to the same url, I do one beforeEach, and then another one on the test, but for some reason I does not understand that I changed the alias. I was doing some reading, and the overriding was fixed,…
Mario Garcia
  • 177
  • 1
  • 4
  • 15
0
votes
1 answer

Wait for certain number of http requests with Cypress

I'm writing a cypress test that tests a map application. When I click on a specific button, I want to wait for all resources to load on the map. Currently, the button is making a request to a url: someurl.com/myData/** Where the ** represents…
user22303309
0
votes
0 answers

CypressError: Timed out retrying after 60000ms: `cy.wait()` timed out waiting `60000ms` for the 1st response to the route:

I'm practicing documentation example of intercept and then used wait alias of intercept but it's giving this error: CypressError: Timed out retrying after 60000ms: `cy.wait()` timed out waiting `60000ms` for the 1st response to the route: `login`.…
Uzair Khan
  • 109
  • 4
0
votes
1 answer

Cypress cy.wait(...) response body is undefined despite setting up fixture in intercept command

I have created Cypress e2e tests that use the following functions: to mock the responses export function getUserAndSupplier(): void { cy.intercept('GET', `${Cypress.env('BaseUrl')}/users/me`, { fixture:…
hubesal
  • 141
  • 3
  • 13
0
votes
1 answer

cy.intercept is not matching the desired url

I am trying to use cy.intercept to match a url, however it seems to be intercepting a different url. I want to intercept the API request made when I click a save button, when this button is clicked, it makes a request to these two endpoints (for…
Hans
  • 3
  • 3
0
votes
3 answers

How to pass content yielded in cy.wait() to the variable and reuse it in the next steps?

I use cy.intercept() and cy.wait() to listen to the request and yield content from it. let number; describe("some test", () => { before(() => { cy.clearCookies(); }); it("some test", () => { cy.someCommand(); …
wojnarto
  • 411
  • 4
  • 9
0
votes
2 answers

Cypress: Switching from cy.route() to cy.intercept()

It seems that most people I read about experence zero trouble with this. I, on the other hand, have a test suite which someone else wrote, in which I'm trying to replace route() with intercept(). The API intercepts are done to handle button clicks…
user9347168
-1
votes
1 answer

Cypress intercept and change the request

I am trying to intercept an a request. This request has a specific endpoint and I would like to change this endpoint. I have now solved it with the following code: cy.intercept('**/i18n/nl.json', { fixture: 'LanguageForItemEditorENG.json'…
E. E. Ozkan
  • 149
  • 10