[Question] Set page route abort before all tests start running.
See original GitHub issueHi, I want to mock all my HTTP requests and abort them before tests start running.
I’ve tried to set that in the global-setup
file but looks like the page return in the tests does not contain the routes.
I have the solution of beforeAll
on every test page, but I want something more general, is it possible?
// global-setup.ts
import { chromium, FullConfig, Route } from "@playwright/test";
async function globalSetup(config: FullConfig) {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.route("**/v1/*/", (route: Route) => {
route.abort();
});
}
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Playwright not able to intercept all requests - Stack Overflow
The issue is, that the requests will be made, after the page is fully loaded from the browser perspective. So you have to...
Read more >How can I stop a route from a route - Apache Camel
Stopping a route during routing an existing message is a bit tricky. The reason for that is Camel will Graceful Shutdown the route...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
In our test both intercepts only spied on the request. Now someone comes along and asks why do we need to reset the...
Read more >Best Practices - Cypress Documentation
Best Practice: Clean up state before tests run. We see many of our users adding code to an after or afterEach hook in...
Read more >Environments and deployments - GitLab Docs
The job with action: stop might not run if it's in a later stage than the job that started the environment. If you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you want to have it for all the pages, you can override the page fixture, apply there your overrides and use this “new instance” everywhere. For example:
See here for more information: https://playwright.dev/docs/test-fixtures#overriding-fixtures
thanks for the response and the help @mxschmitt