Home > Blockchain >  Avoid waiting for get api load in cypress
Avoid waiting for get api load in cypress

Time:05-24

I need a method (or an addition to cy.intercept() ) to be able to ignore waiting for a load for a get. It every time delays the time it takes to execute the test and eats up a lot of time for nothing.

How can I complete or modify cy.intercept('api.link.url' ,null).as('url') so I can exclude it from the load and have the test ignore it? (with null it doesn't work)

I hope I have conveyed all the information correctly. Thank you!

CodePudding user response:

Assuming your website doesn't need the request to complete to actually run the application, and there will be no impact from not returning a real-like response, you can simply return a 200.

cy.intercept('/foo', {statusCode: 200}).as('url')

If you do need a response body, I'd suggest saving that response into a file in your fixtures/ folder, and returning that response.

cy.intercept('/foo', {statusCode: 200, fixture: 'bar'}).as('url')

CodePudding user response:

Use an empty object instead of null

cy.intercept('api.link.url' , {})
  • Related