* Revert "fix(hooks): separate test timeout from beforeAll/afterAll timeouts (#12413)"
This reverts commit 73dee69558.
* Revert "fix(test-runner): rely on test title paths instead of ordinal (#12414)"
This reverts commit d744a87aee.
* Revert "chore(test runner): run hooks/modifiers as a part of the test (#12329)"
This reverts commit 47045ba48d.
It's a straightforward change to support new, common, keyboard commands
Note that I've tested this locally with Chrome on my Mac but it seems that CI doesn't want to pass Chrome tests - it's running on ubuntu though. Does this mean that I should introduce per-platform editing commands? At the moment there is only a single [`macEditingCommands`](0ed33522c5/packages/playwright-core/src/server/macEditingCommands.ts) file.
References https://github.com/microsoft/playwright/issues/12000
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
This uses `Module._resolveFilename` to intercept module resolution and
check `tsconfig.paths` similarly to pirates usage ot `Module._compile`.
Previously, we resolved during compilation that required reproducible
resolution due to caching. Now we can resolve as we go and support
all `tsconfig.paths`.
This reverts commit e5c9d1e39f.
Reason for revert: turns out this fix results in a 5-second delay
when starting tests in docker, with `test-results` folder being
a non-removable mount.
The reason for the delay is the `maxBusyTries` option that we
supply by default to rimraf when trying to remove the folder.
While this option might come handy when removing temporary
browser profile folder, it doesn't serve us well in this particular
usecase.
References #12106
In experimental ESM mode a child process is forked in order to run the tests. Currently the exit code of this child process is not propagated to the exit code of the parent process, which means that the process exits with a status code of `0` even if some of the tests failed.
This makes it difficult to use Playwright in CI in experimental mode, as the CI pipeline as a whole will pass despite the test failures.
This change addresses this by propagating the exit code in the case where it is non-zero.
This changes PlaywrigtServer to serve connections like `ws://localhost:3333/?browser=chromium`:
- launches the browser;
- talks `browserType.connect`-style protocol over websocket;
- compatible with `connectOptions` fixture.
```js
await playwright.chromium.connect({ wsEndpoint: 'ws://localhost:3333/?browser=chrome' });
```
This option stops all kinds of CSS animations while doing screenshot:
- CSS animations
- CSS transitions
- Web Animations
Animations get different treatment depending on animation duration:
- finite animations are fast-forwarded to its end, issuing the
`transitionend` event.
- Infinite animations are resetted to its beginning, and then
resumed after the screenshot.
References #9938, fixes#11912
This introduces `locator('div', { has: locator })` syntax that matches elements containing other elements.
Can be used together with `hasText`.
Internally, has selector engine takes an inner selector escaped with double-quotes:
`div >> has="li >> span >> text=Foo" >> span`.
When element that is being dragged stays under the mouse,
it prevents the hit target check on drop from working,
because drop target is overlayed by the dragged element.
To workaround this, we perform a one-time hit target check
before moving for the drop, as we used to.
These variables aren't CLI-only anymore, so pick some more general
names for them.
Note: all language ports would need to follow-up with the rename
after the next roll.
Fixes#11450
This reworks DeadlineRunner to use exception to signal timeout. This way,
we'll be able to run fixtures against a shared deadline vs their own
deadline and still get an easy control-flow timeout handling.
In several of the Playwright APIs, falsey values were not handled correctly. This changeset adds tests (and some fixes):
- route.continue: If options.postData was the empty string, the continue failed to override the post data.
- page.post (application/json with options.data: false|''|0|null): Raw falsey values were getting dropped (i.e. you can't do the equivalent of curl --header application/json … -d 'false'). This has been fixed with most values across all browsers, but an additional fix is needed for 'null' which the channel serializer treats extra specially.
- testInfo.attach: This didn't get reported as an error when options.path was the empty string, but should have been.
#11413 (and its fix#11414) inspired this search as they are the same
class of bug.
- Use file path, not content to calculate the attachment hash.
- Always cleanup fixture from the list on teardown, to avoid reporting
teardown error multiple times: from the test, and from the cleanup.
We do not have a timeout for any other close method, such as
browserContext.close or browser.close, and hitting default
30 seconds is very realistic with large Electron apps.
In case of self-hosted github runners, it's much easier to checkout
under `playwright-internal` folder name instead of a default
`playwright` name. This confuses our stack collection.
This patch makes it generic.
This changes previous layout shift attempt (see #9546)
to account for more valid usecases:
- On the first event that is intercepted we enforce the hit target. This
is similar to the current mode that checks hit target before the action,
but is better timed.
- On subsequent events we assume that everything is fine. This covers more
scenarios like react rerender, glass pane on mousedown, detach on mouseup.
This check is enabled by default, with `process.env.PLAYWRIGHT_NO_LAYOUT_SHIFT_CHECK`
to opt out.
## Before
* When docker wasn't running: crashed with a TypeError
* When any image without `RepoTags` was present: crashed with TypeError
* Typo in recommended command ("playwight")
* No indication of `PW_TEST_IMAGE` env var in error output
<details>
<summary>Docker not running</summary>
```
Using config at ~redacted/playwright.config.ts
ERROR get /images/json 500 dial unix docker.raw.sock: connect: connection refused
TypeError: Cannot read property 'find' of null
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:43:9)
at GridServer.createAgent (~redacted/node_modules/playwright-core/lib/grid/gridServer.js:356:5)
at launchDockerContainer (~redacted/node_modules/@playwright/test/lib/cli.js:259:3)
at Runner._run (~redacted/node_modules/@playwright/test/lib/runner.js:236:98)
Running 1 test using 1 worker
test.ts:9:1 › some redacted description
ERROR get /images/json 500 dial unix docker.raw.sock: connect: connection refused
TypeError: Cannot read property 'find' of null
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js
```
</details>
<details>
<summary>Image without repo tags</summary>
```
Using config at ~redacted/playwright.config.ts
TypeError: Cannot read property 'includes' of undefined
at ~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:55
at Array.find (<anonymous>)
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:43:9)
at GridServer.createAgent (~redacted/node_modules/playwright-core/lib/grid/gridServer.js:356:5)
at launchDockerContainer (~redacted/node_modules/@playwright/test/lib/cli.js:259:3)
at Runner._run (~redacted/node_modules/@playwright/test/lib/runner.js:236:98)
Running 1 test using 1 worker
some-test.ts › some description
TypeError: Cannot read property 'includes' of undefined
at ~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:55
at Array.find (<anonymous>)
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:67:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.j ✘ editor-editor-wysiwyg--editor-wysiwyg.vr.ts:9:1 › actual element matches expected element (26ms)
1) some-test.ts › some description =====
'Grid agent creation failed'
1 failed
some-test.ts › some description ======
```
</details>
## After
* Helpful error message if docker isn't running
* Doesn't crash when local-only images in list
* No typo in `playwright install docker-image` command
* When other playwright images are found they are listed and `PW_TEST_IMAGE` is mentioned
### After: Docker not running
```
Using config at ~redacted/playwright.config.ts
Error fetching json: Error: connect ECONNREFUSED /var/run/docker.sock
Error:
╔═════════════════════════════════════════╗
║ Failed to list docker images ║
║ Please ensure docker daemon is running. ║
║ ║
║ <3 Playwright Team ║
╚═════════════════════════════════════════╝
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:61:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:43:9)
at GridServer.createAgent (~redacted/node_modules/playwright-core/lib/grid/gridServer.js:356:5)
at launchDockerContainer (~redacted/node_modules/@playwright/test/lib/cli.js:259:3)
at Runner._run (~redacted/node_modules/@playwright/test/lib/runner.js:236:98)
Running 1 test using 1 worker
test.ts:9:1 › description
Error fetching json: Error: connect ECONNREFUSED /var/run/docker.sock
Error:
╔═════════════════════════════════════════╗
║ Failed to list docker images ║
║ Please ensure docker daemon is running. ║
║ ║
║ <3 Playwright Team ║
╚═════════════════════════════════════════╝
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:61:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.j ✘ test.ts:9:1 › description
1) test.ts:9:1 › description =====
'Grid agent creation failed'
1 failed
test.ts:9:1 › description ======
```
## After: No exact match found
```
Using config at ~redacted/playwright.config.ts
Error:
╔════════════════════════════════════════════════════════════════════════════╗
║ Failed to find mcr.microsoft.com/playwright:v1.16.3-focal docker image. ║
║ ║
║ Available images: ║
║ - mcr.microsoft.com/playwright:v1.16.3 ║
║ - mcr.microsoft.com/playwright:v1.16.2-focal ║
║ ║
║ Use available images via PWTEST_IMAGE_NAME environment variable: ║
║ PWTEST_IMAGE_NAME=mcr.microsoft.com/playwright:v1.16.3 playwright test ║
║ ║
║ Alternatively, please pull docker image with the following command: ║
║ ║
║ npx playwright install docker-image ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════════════════════╝
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:92:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:43:9)
at GridServer.createAgent (~redacted/node_modules/playwright-core/lib/grid/gridServer.js:356:5)
at launchDockerContainer (~redacted/node_modules/@playwright/test/lib/cli.js:259:3)
at Runner._run (~redacted/node_modules/@playwright/test/lib/runner.js:236:98)
Running 1 test using 1 worker
editor-editor-wysiwyg--editor-wysiwyg.vr.ts:9:1 › actual element matches expected element
Error:
╔════════════════════════════════════════════════════════════════════════════╗
║ Failed to find mcr.microsoft.com/playwright:v1.16.3-focal docker image. ║
║ ║
║ Available images: ║
║ - mcr.microsoft.com/playwright:v1.16.3 ║
║ - mcr.microsoft.com/playwright:v1.16.2-focal ║
║ ║
║ Use available images via PWTEST_IMAGE_NAME environment variable: ║
║ PWTEST_IMAGE_NAME=mcr.microsoft.com/playwright:v1.16.3 playwright test ║
║ ║
║ Alternatively, please pull docker image with the following command: ║
║ ║
║ npx playwright install docker-image ║
║ ║
║ <3 Playwright Team ║
╚════════════════════════════════════════════════════════════════════════════╝
at launchDockerGridAgent (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.js:92:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.launch (~redacted/node_modules/playwright-core/lib/grid/dockerGridFactory.j ✘ test.ts:9:1 › description
1) test.ts:9:1 › description =====
'Grid agent creation failed'
1 failed
test.ts:9:1 › description ======
```