Skip to content
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

[Bug]: Trace network showing duplicate requests when using beforeAll/afterAll #33106

Open
jeremy-daley-kr opened this issue Oct 15, 2024 · 1 comment
Assignees
Labels

Comments

@jeremy-daley-kr
Copy link
Contributor

Version

1.47.2

Steps to reproduce

Run this simple test with the --trace=on flag, so you can see the trace network requests:

import { expect, Page, test } from '@playwright/test';

test.describe('POC', async () => {
  let page: Page;

  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
    // Intercept to see a specific request. Should only log once.
    await page.route(/redirection\.js/, async (route) => {
      console.log(route.request().url());
      await route.continue();
    });
    await page.goto('https://playwright.dev');
  });

  test.beforeEach(async () => {
    await page.goto('https://google.com/');
  });

  // Removing this makes only 2x duplication, instead of 3x
  test.afterAll(async () => {
    await page.close();
  });

  test('should work', async () => {
    await expect(page).toHaveTitle(/[a-z]/);
  });
});

Expected behavior

Trace network requests should match the intercepted requests logged... only 1.

Actual behavior

All trace network requests appear to be tripled, even though the intercepted console logs in the test show just one. I don't believe the requests are actually firing 3 times... it just appears that way.

Image

Additional context

No response

Environment

System:
OS: macOS 14.4.1
Memory: 80.97 MB / 16.00 GB
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 3.6.1 - ~/.nvm/versions/node/v18.17.1/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
playwright: 1.47.2 => 1.47.2
playwright-lighthouse: ^4.0.0 => 4.0.0

@mxschmitt
Copy link
Member

mxschmitt commented Oct 15, 2024

I can repro. More minimal repro:

import { Page, test } from '@playwright/test';

test.describe('POC', async () => {
  let page: Page;

  test.beforeAll(async ({ browser }) => {
    page = await browser.newPage();
  });

  test('should work', async () => {
    await page.goto('https://playwright.dev');
  });
  
  // This results in the duplication
  test.afterAll(() => {});
  test.afterAll(() => {});
  test.afterAll(() => {});
  test.afterAll(() => {});
});

Good: 1.45.0

Bad: 1.46.0

diff: 1b4d900...37ffbd7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants