playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] .route() causes browser issues and fails test in vscode but ok on CI

Open debs-obrien opened this issue 2 years ago • 1 comments

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');
});
Screenshot 2022-12-01 at 20 13 27 Screenshot 2022-12-01 at 20 18 46

For full repo: https://github.com/debs-obrien/debbie.codes/blob/master/tests/award-links.spec.ts

debs-obrien avatar Dec 01 '22 19:12 debs-obrien

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

dgozman avatar Dec 15 '22 17:12 dgozman