Sam152 / cypress-replay

Records requests made to your services in Cypress tests and stores them in fixture files for replay on CI.
6 stars 3 forks source link

Replaying does not wait for pending requests to complete, making them non-deterministic #18

Open antischematic opened 1 year ago

antischematic commented 1 year ago

Related to https://github.com/Sam152/cypress-replay/issues/12

It's the same problem as before. Tests are completing before the recorded stubs play out, even with delay override set to 0. This causes some requests to fall into the next test case, which there is no stub for. In some cases this causes tests to fail due to failed network requests that should have been stubbed.

We need to add a wait in replay mode that matches the recording behaviour.

antischematic commented 1 year ago

Worth noting that I had to simulate 6x CPU slowdown to get some of my tests to fail on my local machine. The problem only became apparent once I ran them on CI.

Sam152 commented 1 year ago

So getting this clear in my mind, once req.reply is called, we should wait until the after:response event is fired before allowing the test to complete?

I do not fully understand why this would fail the next test case. I would imagine between tests when things are mounted and unmounted, the beforeEach function is run again and things are in a relatively fresh state.