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]: Overridden browser fixture does not work as expected #30726

Closed
mdmundo opened this issue May 9, 2024 · 4 comments
Closed

[Bug]: Overridden browser fixture does not work as expected #30726

mdmundo opened this issue May 9, 2024 · 4 comments
Assignees
Labels

Comments

@mdmundo
Copy link

mdmundo commented May 9, 2024

Version

1.44.0

Steps to reproduce

Expected behavior

Both browser windows are kept opened until you close them

Actual behavior

The one that is using the overridden browser fixture closes after ~30s

Additional context

Both fixtures share the following code:

const browser = await playwright.chromium.launch({ headless: false });
await use(browser);
await expect(() => {
  expect(
    browser
      .contexts()
      .every((context) => context.pages().every((page) => page.isClosed()))
  ).toBe(true);
}).toPass({ intervals: [2_000] });

expect.toPass should prevent the browser from closing after being used in test, but it does not work if you are using the overridden browser fixture.

Environment

lstat
ENOENT: no such file or directory, lstat
This is related to npm not being able to find a file.
@dgozman
Copy link
Contributor

dgozman commented May 13, 2024

@mdmundo Thank you for the repro, illustrates the question nicely!

The difference between the two fixtures is that browser is a worker-scoped fixture, while chromium is a test-scoped fixture.

So, when using the browser fixture:

  • Test successfully finishes.
  • Test-scoped fixtures are successfully teared down.
  • Playwright initiates worker termination, which includes tearing down the browser fixture.
  • Playwright ensures a 30 seconds maximum limit on the worker teardown, and kills the worker process after that. The browser is forcefully closed. Note there is a similar issue [Bug]: Worker-scoped fixture execution terminates before timeout #30504 that advocates for a customizable timeout for worker fixture teardown.

When using the chromium fixture:

  • Test successfully finishes.
  • Teardown for test-scoped fixtures is initiated, which includes tearing down the chromium fixture.
  • Since chromium never finishes, Playwright does not consider the test to be finished. Given that you set timeout: 0 in the config, Playwright waits indefinitely for the test to finish.

Given the above, it seems like things work as intended. Let me know what you think.

@mdmundo
Copy link
Author

mdmundo commented May 14, 2024

@dgozman should not it be able to override timeout with this? { scope: "worker", timeout: 0 }

export const test = base.extend({
  browser: [
    ({ browser }, use) => use(browser),
    { scope: "worker", timeout: 0 },
  ],
});

@dgozman
Copy link
Contributor

dgozman commented May 14, 2024

@mdmundo Yep, this should work once #30504 is fixed. I'll close this issue, since there is no action item for Playwright. Thank you for filing!

@dgozman dgozman closed this as completed May 14, 2024
@mdmundo
Copy link
Author

mdmundo commented May 14, 2024

@dgozman thanks for the explanation!

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

3 participants