-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Removing routes from page._routes #1607
Comments
Are you using jest-playwright? We should make sure it creates new browser context for every test. That way you would not be affected by the state of the previous test run in the subsequent one. |
yeah! i am using jest-playwright, but i think a new browser context for every test may be a good option instead of the solution. Since we're porting over tests from puppeteer, some tests are written on top of each other. i think it'd make tests go exponentially longer (though, i get it, more scalable) if you have to "start" from scratch for each one, especially if you did field validation tests that each input would be starting from a new browsing context. |
There is now wait to unroute. |
Leaving this here for reference: EDIT: Also, when passing RegExp to url, make sure to pass the same object. THIS WORKS const myroute = /myroute/
await page.route(myroute, handler)
await page.unroute(myroute) THIS DOES NOT WORK await page.route(/myroute/, handler)
await page.unroute(/myroute/) // WRONG This is because |
@aesyondu I owe you a beer, I was struggling with exactly that until I found your answer 😄 |
currently using playwright to test api responses from a button click, but once I establish a page.route(...) for a specific url, that handler can never be overridden by future page.route(...) with the same URLs on that page instance. so for now, in my afterEach, i have this: (is this the right way to have a new route handler override for the same route url?):
So my tests currently look like this:
is there a way for page.route to look for overlapping urls and take the newest handler?
The text was updated successfully, but these errors were encountered: