playwright
playwright copied to clipboard
[BUG] .route() causes browser issues and fails test in vscode but ok on CI
Context:
- Playwright Version: 1.28
- Operating System: Mac
- Node.js version: 16
- Browser: Chromium
- Extra: [any specific details about your environment]
When running tests with .route() through the vs code extension with show browser open the main window keeps a loading spinner going and basically crashes meaning you need to manually close the browser in order to continue running tests.
Running all tests locally will fail due to having multiple tests with .route(). You have to manually close the browser and run tests one by one manually closing browser after each test. All tests will pass on CI.
test('microsoft mvp link in home page works', async ({ page }) => {
await page.context().route('https://mvp.microsoft.com/**', route => route.fulfill({
body: '<html><body><h1>Microsoft MVP</h1></body></html>'
}));
const [page1] = await Promise.all([
page.waitForEvent('popup'),
await page.getByRole('link', { name: 'Former Microsoft MVP' }).click()
]);
await expect(page1).toHaveURL('https://mvp.microsoft.com/en-us');
});
For full repo: https://github.com/debs-obrien/debbie.codes/blob/master/tests/award-links.spec.ts
I tried the following:
git clone https://github.com/debs-obrien/debbie.codes.git
cd debbie.codes
npm i
npx playwright install
npx playwright test --project=chromium --grep="microsoft mvp link in home page works"
Somehow it works for me:
Running 1 test using 1 worker
1 passed (2s)
To open last HTML report run:
npx playwright show-report