microsoft/playwright-test

How can I update mock fixture at test runtime?

haikyuu opened this issue · 2 comments

My use case is quite simple:

  • my app performs a request to the backend -> some state is ON
  • expect the UI to display ON
  • my app performs a request to the backend -> some state is OFF
  • expect UI to display OFF

I used fixtures to mock a couple of routes, and I want to re-mock one route in the middle of my test. I've tried to do that, but it didn't work:

// test...
mockedContext.route(...)
// more tests

If it's not possible to implement now, is there a workaround that can work for me?

It turns out I can call page.route(...) the same way. It's a good thing to add to the network mocking docs.

The new test-runner is quite different which got released yesterday. Please create a new issue if you still face into that issue.