microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.99k stars 3.67k forks source link

[Bug]: Failed worker ran from expect assertion #33477

Closed mastrzyz closed 1 week ago

mastrzyz commented 1 week ago

Version

1.47.2

Steps to reproduce

This is very hard to reproduce locally, I have only seen it in CI at around ~95% repeatability

Expected behavior

The following code passes/fails without bringing down the worker

    expect(
      page.getByTestId(`people-picker-no-results`)
    ).toBeVisible();

Actual behavior

Error: expect(locator).toBeVisible()

Locator: getByTestId('people-picker-entry-user1@testcompany.com')
Expected: visible
Received: <element(s) not found>
Call log:
  - expect.toBeVisible with timeout 5000ms
  - waiting for getByTestId('people-picker-entry-user1@testcompany.com')

AFTER

Failed worker ran 4 tests:

    at captureRawStack (D:\a\_work\1\a\node_modules\playwright-core\lib\utils\stackTrace.js:49:17)
    at Proxy.<anonymous> (D:\a\_work\1\a\node_modules\playwright\lib\matchers\expect.js:206:84)
    atREMOVED.playwright.ui.test.ts:59:1

Additional context

No response

Environment

System: OS: Windows 11 10.0.26100 CPU: (20) x64 Intel(R) Core(TM) i9-10900X CPU @ 3.70GHz Memory: 21.61 GB / 47.72 GB Binaries: Node: 20.11.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD bun: 1.1.4 - ~.bun\bin\bun.EXE IDEs: VSCode: 1.95.1 - C:\Users\REMOVED\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD Languages: Bash: 5.1.16 - C:\WINDOWS\system32\bash.EXE

mastrzyz commented 1 week ago

I have a hunch!

could it be due to this NOT awaiting any of its


   expect(
      page.getByTestId(`people-picker-no-results`)
    ).toBeVisible();
``` ?

It has 4 of them
yury-s commented 1 week ago

await is missing before the expect call:

  await expect(
      page.getByTestId(`people-picker-no-results`)
    ).toBeVisible();

You can consider adding lint rules to avoid non-awaited promises.

mastrzyz commented 1 week ago

@yury-s the ask here is to have Playwright more gracefully close/stop . Is it expected behavior to have a worker error here?

mastrzyz commented 5 days ago

@yury-s does that seem fair? I understand that there is a lint rule but that can be bypassed easily unfortunately.