cypress-autorecord icon indicating copy to clipboard operation
cypress-autorecord copied to clipboard

Wait route

Open chaosmirage opened this issue 5 years ago • 2 comments

Hello. I have a problem.

In my test I want to describe sequence of commands, where each command should wait response from mock and go to next command.

How can I do this with this plugin?

Now when I try use use:

cy.server()

cy.route({
    method: 'GET',
    url: 'my-url',
}).as('routeName');

cy.wait('@routeName')

this plugin stops to mock this request

chaosmirage avatar Jun 28 '19 13:06 chaosmirage

Hi @chaosmirage

It is the default behaviour of Cypress that if you don't pass in a response on a route that it would pass the route through without stubbing. You can read more about it here: https://docs.cypress.io/api/commands/route.html#Without-Stubbing

Let me look into this on my end to see if theres any hacks around it but for now, your best bet is to use a cy.wait(time).

Nanciee avatar Jul 05 '19 02:07 Nanciee

I tried to implement a similar solution in your library: https://github.com/Cloudo/cy-auto-stub/blob/master/src/commands.js

But my attempt was unsuccessful.

Perhaps this example will inspire you.

Thank you for this tool!

chaosmirage avatar Jul 05 '19 11:07 chaosmirage