Shlomy Z
Shlomy Z

Reputation: 331

Cypress - stubbing using route(options) isn't work

I try to simulate bad request by returning status code = 400.

I followed the documentation and found that I need to use the route function with an options:

cy.route({method : 'GET',url: 'users',status: 400});
cy.route({method : 'GET',url: '**/users/*',status: 400});

Both of those didn't work - running the Cypress Test Runner - the request isn't captured and the request is against the real server. Please help. Thanks!

Upvotes: 4

Views: 1244

Answers (1)

user4562
user4562

Reputation: 41

In case someone will come across this issue, you need to pass response as one of the parameters, like this:

cy.route({
  method : 'GET',
  url: 'users',
  status: 400,
  response: {}
});

Upvotes: 4

Related Questions