Commit Graph

1208 Commits

Author SHA1 Message Date
Dmitry Gozman
6b48631eed
feat(role): add more tests for accessible name (#13154) 2022-03-29 11:59:44 -07:00
github-actions[bot]
54f6e5db19
feat(firefox): roll to r1322 (#13150)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-29 11:28:20 -07:00
github-actions[bot]
29e0525926
feat(firefox-beta): roll to r1321 (#13142)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-29 01:16:25 -07:00
Pavel Feldman
1961959dcb
chore: migrate injected scripts to esbuild (#13143) 2022-03-28 23:10:17 -07:00
Dmitry Gozman
de0af27837
feat(test runner): show last tests in the worker on teardown error (#13139) 2022-03-28 19:58:24 -07:00
Pavel Feldman
8758cf8cbf
chore: migrate html reporter to vite (#13116) 2022-03-28 18:21:19 -07:00
Dmitry Gozman
d59c2b996f
fix(parallel): minimize the number of beforeAll/afterAll hooks in parallel mode (#13138)
Previously, we always formed groups consisting of a single test.
Now, we group tests that share `beforeAll`/`afterAll` hooks into
`config.workers` equally-sized groups.
2022-03-28 16:10:32 -07:00
Ross Wollman
ae365dda3b
chore: remove internal dep on FullConfig (#13074)
Resolves #13058.

This blocks adding #8206 since we don't want the new launch configs
publicly available on FullConfig.
2022-03-28 15:53:42 -07:00
Dmitry Gozman
01a39e5b4c
test(role): add tests for implicit role calculation (#13132) 2022-03-28 15:22:50 -07:00
Philip Sanetra
be41c4a35d
fix(registry): Fix support for generic-linux (#13129)
Fixes https://github.com/microsoft/playwright/issues/13128
2022-03-28 14:50:56 -07:00
Dmitry Gozman
9420a53939
fix(esm): make sure import from './foo.js' is supported (#13137)
Drive-by: migrate all @esm tests to esm.spec.ts.
2022-03-28 14:37:46 -07:00
Dmitry Gozman
8c19f71c36
feat(selectors): role selector engine (#12999)
This introduces `role=button[name="Click me"][pressed]` attribute-style
role selector. It is only available under `env.PLAYWRIGHT_EXPERIMENTAL_FEATURES`.

Supported attributes:
- `role` is required, for example `role=button`;
- `name` is accessible name, supports matching operators and regular expressions:
  `role=button[name=/Click(me)?/]`;
- `checked` boolean/mixed, for example `role=checkbox[checked=false]`;
- `selected` boolean, for example `role=option[selected]`;
- `expanded` boolean, for example `role=button[expanded=true]`;
- `disabled` boolean, for example `role=button[disabled]`;
- `level` number, for example `role=heading[level=3]`;
- `pressed` boolean/mixed, for example `role=button[pressed="mixed"]`;
- `includeHidden` - by default, only non-hidden elements are considered.
   Passing `role=button[includeHidden]` matches hidden elements as well.
2022-03-28 09:24:58 -07:00
Yury Semikhatsky
5734c18ef8
feat(route): add cors header in route.fulfill (#12943) 2022-03-25 14:56:57 -07:00
Andrey Lushnikov
4ab4c0bda1
feat: detect docker version and Playwright version mismatch (#12806)
This patch prints a friendly instructions in case Docker image version
mismatches Playwright version and there are missing browser
dependencies.

With this patch, Playwright will yield the following error:

```
root@f0774d2b2097:~# node a.mjs
node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

browserType.launch:
╔════════════════════════════════════════════════════════════════════════════════════════════╗
║ Host system is missing dependencies to run browsers.                                       ║
║ This is most likely due to docker image version not matching Playwright version:           ║
║ - Playwright: 1.22.0                                                                       ║
║ -     Docker: 1.21.0                                                                       ║
║                                                                                            ║
║ Either:                                                                                    ║
║ - (recommended) use docker image "mcr.microsoft.com/playwright:v1.22.0-focal"              ║
║ - (alternative 1) run the following command inside docker to install missing dependencies: ║
║                                                                                            ║
║     npx playwright install-deps                                                            ║
║                                                                                            ║
║ - (alternative 2) use Aptitude inside docker:                                              ║
║                                                                                            ║
║     apt-get install libgbm1                                                                ║
║                                                                                            ║
║ <3 Playwright Team                                                                         ║
╚════════════════════════════════════════════════════════════════════════════════════════════╝
    at file:///root/a.mjs:3:10 {
  name: 'Error'
}```

Fixes #12796

Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
2022-03-25 14:45:53 -07:00
Pavel Feldman
6b81e76c2b
chore: migrate trace-viewer and recorder to vite (#13076) 2022-03-25 14:12:00 -07:00
Yury Semikhatsky
97e8ead57c
feat: large files upload in ff and wk (#12937) 2022-03-25 13:26:12 -07:00
Max Schmitt
c8cc62a2e6
chore: add link validation for docs (#13047) 2022-03-25 19:30:45 +01:00
Pavel Feldman
3f1cb7b8e6
chore: only restart esm on Node 16+ (#12955) 2022-03-25 08:44:42 -07:00
Pavel Feldman
81d412216a
fix: list files when config writes to output (#13023) 2022-03-25 08:44:27 -07:00
Pavel Feldman
07c1a27732
chore(deps): prepare deps for monorepo (#13057) 2022-03-25 08:43:29 -07:00
github-actions[bot]
7a67c6d264
feat(webkit): roll to r1621 (#13056) 2022-03-25 08:40:19 -07:00
Max Schmitt
1797c5c249
chore(test-runner): support self signed certificate in webServer (#13032) 2022-03-24 17:30:52 +01:00
github-actions[bot]
8f6df440d5
feat(firefox-beta): roll to r1320 (#13010) 2022-03-24 07:49:50 -07:00
github-actions[bot]
920df240d1
feat(firefox): roll to r1321 (#13017) 2022-03-24 07:49:27 -07:00
Yury Semikhatsky
136c4e10e6
Revert "chore: align setInputFiles in webkit with other browsers (#13011)" (#13021)
This reverts commit 7fe763c1fc.
2022-03-24 07:46:37 -07:00
Dmitry Gozman
91408f2c5e
fix(storageState): provide nice error message for storage state issues (#13019) 2022-03-24 07:33:51 -07:00
Dmitry Gozman
3688e74e3e
fix(list mode): print errors to stderr (#13016)
`--list` mode now prints any errors encountered during test collection,
for example syntax errors, to `stderr`.
2022-03-24 07:33:33 -07:00
Yury Semikhatsky
7fe763c1fc
chore: align setInputFiles in webkit with other browsers (#13011) 2022-03-23 16:07:47 -07:00
Andrey Lushnikov
e1700bd167
feat: use package.json directory as a default for outputDir (#12942)
This patch:
- starts using directory of `package.json` to resolve default
  output directory path
- starts using either `package.json` directory or configuration
  directory to resolve all relative paths

References #12970
2022-03-23 16:05:49 -07:00
Ross Wollman
39376cccd8
fix: allow unnamed cookies (#12991)
Fixes #12808.
2022-03-23 15:50:43 -07:00
Andrey Lushnikov
bbc1a4fea0
fix: print all missing libraries when used on unsupported linux distro (#12966)
This patch:
- Adds 3 new host platform types:
  * `generic-linux` and `generic-linux-arm64` for the unsupported
    linux distributions
  * `<unknown>` for non-supported OS versions
- Prints a warning when downloading Ubuntu browser builds on
  unsupported Linux distribution
- Makes sure launch doctor prints all missing shared libraries
  on unknown Linux distributions
- Also prints an `apt` command as an alternative to Playwright CLI
  dependency installation.
2022-03-23 14:06:14 -07:00
github-actions[bot]
53b84541ab
feat(chromium): roll to r983172 (#12995)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-23 20:34:23 +01:00
github-actions[bot]
2d5762c842
feat(webkit): roll to r1620 (#12971) 2022-03-23 11:30:42 -07:00
Max Schmitt
b69d0566bb
chore: disable Chromium CertificateTransparencyComponentUpdater feature (#12992) 2022-03-23 19:14:22 +01:00
Andrew Hayward
ab39cfcb18
docs: fixing example code in accessibility API docs (#12664)
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
2022-03-23 11:50:35 +01:00
Dmitry Gozman
722302799e
feat(selectors): support regular expressions in attribute selectors (#12960)
Supports inline regex in addition to string: `_react=BookItem[author = /Ann?a/i]`.
This is similar to `text=` selector, but applies to `_react` and `_vue`
selectors. In the future, will also apply to `role=` selector.
2022-03-22 17:00:56 -07:00
Ross Wollman
541fb39a51
feat(html-reporter): add report context header (#12734)
Resolves #11318.

* Adds `TestConfig.attachments` public API. (We opted to not implement an analog to the async `TestInfo.attach(…)` API.)
* Adds `TestConfig.attachments` to common reporters.
* Dogfoods some git and CI-info inference to generate useful atttachments
* Updates HTML Reporter to include a side bar to present a pre-defined set of attachments (a.k.a git/commit context sidebar)

Here's what it looks like:

<img width="1738" alt="Screen Shot 2022-03-21 at 3 23 28 PM" src="https://user-images.githubusercontent.com/11915034/159373291-8b937d30-fba3-472a-853a-766018f6b3e2.png">

See `tests/playwright-test/reporter-html.spec.ts` for an example of usage (for dogfood-ing only). In the future, if this becomes user-facing, there the Global Setup bit would likely become unnecessary (as would interaction with attachments array); there would likely just be a nice top-level config and/or CLI flag to enable collecting of info.
2022-03-22 16:28:04 -07:00
Brian Rhoten
fb83d4b42c
fix(codegen): do not consider empty attributes for selector generation (#12880)
Co-authored-by: Brian Rhoten <brhoten@appriss.com>
2022-03-22 13:56:33 -07:00
Brandon Walderman
7db40071a8
fix(selenium): Use ms:edgeOptions with Edge. (#12933) 2022-03-22 12:46:00 -07:00
Max Schmitt
2a7370bad2
fix: upgrade json5 dependency (#12946)
Fixes #12940
2022-03-22 11:33:23 -07:00
Max Schmitt
d8ab76bf64
chore: throw when a Promise was passed to toMatchSnapshot (#12906) 2022-03-22 16:36:09 +01:00
Dmitry Gozman
4b877213a1
fix(tracing): preserve control values without modifying DOM (#12939)
Previously, we preserved input/textarea values by providing
`value` attribute or text child. This produces DOM that does not
actually match the original page.

This change starts using special attributes to modify values
directly when rendering.

Same treatment is also applied to options in `select` and
`checked` property of checkboxes and radio buttons.
2022-03-21 18:51:48 -07:00
Dmitry Gozman
dea6528c0c
feat(aria): introduce role utils (#12916)
This includes aria role and accessible name computation.
Accessible name is covered by wpt tests.
2022-03-21 17:26:45 -07:00
Andrey Lushnikov
7f51336068
fix: allow toMatchSnapshot to use text comparator for text data (#12934)
This was regressed awhile ago.

In v1.17 we shipped the following code: 30e15ad36f/packages/playwright-test/src/matchers/golden.ts (L122-L131)

`toMatchSnapshot` should fallback to text comparator in case of
unknown extension and string data.

Fixes #12862
2022-03-21 16:42:21 -07:00
github-actions[bot]
478a75401a
feat(webkit): roll to r1619 (#12905) 2022-03-21 15:15:56 -07:00
Andrey Lushnikov
c18077c0de
feat(toHaveScreenshot): align screenshot generation & comparison (#12812)
This patch aligns the strategies that are used to generate new
screnshot expectations and to compare screenshot expectations against
baseline.

With this patch, `toHaveScreenshot` will:
- when generating a new expectation: will wait for 2 consecutive
  screenshots to match and accept the last one as expectation.
- when given an expectation:
  * will compare first screenshot against expectation. If matches,
    resolve successfully
  * if first screenshot doesn't match, then wait for 2 consecutive
    screenshots to match and then compare last screenshot with the
    expectation.

An example of a new detailed call log:

```
  1) a.spec.ts:3:1 › should work ===================================================================

    Error: Screenshot comparison failed:

      20000 pixels (ratio 0.03 of all image pixels) are different

    Call log:
      - expect.toHaveScreenshot with timeout 5000ms
      -   verifying given screenshot expectation
      - fast-path: checking first screenshot to match expectation
      - taking page screenshot
      -   disabled all CSS animations
      -   waiting for fonts to load...
      -   fonts in all frames are loaded
      - fast-path failed: first screenshot did not match expectation - 20000 pixels (ratio 0.03 of all image pixels) are different
      - waiting for 2 consecutive screenshots to match
      - waiting 100ms before taking screenshot
      - taking page screenshot
      -   disabled all CSS animations
      -   waiting for fonts to load...
      -   fonts in all frames are loaded
      - 2 consecutive screenshots matched
      - final screenshot did not match expectation - 20000 pixels (ratio 0.03 of all image pixels) are different
      - 20000 pixels (ratio 0.03 of all image pixels) are different

    Expected: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-expected.png
    Received: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-actual.png
        Diff: /Users/andreylushnikov/tmp/test-results/a-should-work/should-work-1-diff.png

      3 | test('should work', async ({ page }) => {
      4 |   await page.goto('file:///Users/andreylushnikov/prog/playwright/tests/assets/rotate-z.html');
    > 5 |   await expect(page).toHaveScreenshot();
        |                      ^
      6 | });
      7 |
```
2022-03-21 15:10:33 -07:00
github-actions[bot]
67e754f6b5
feat(firefox): roll to r1320 (#12928) 2022-03-21 13:40:41 -07:00
Yury Semikhatsky
0adf5536af
docs(fetch): clarify cookie handling (#12892) 2022-03-21 13:20:17 -07:00
github-actions[bot]
9a60067fc2
feat(chromium): roll to r982481 (#12903)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-19 13:06:55 +01:00
Pavel Feldman
e044bae888
chore: make count() work with _vue selectors (#12899) 2022-03-18 21:22:33 -07:00
Dmitry Gozman
85b01056b6
fix(click): workaround elementsFromPoint issue in Chromium (#12888)
Block elements inside elements are not returned correctly
from `document.elementsFromPoint(x, y)` in some cases.
See https://bugs.chromium.org/p/chromium/issues/detail?id=1307458 for details.
2022-03-18 18:20:48 -07:00
Pavel Feldman
98ed81dc00
chore: do not initialize full sessions for pages used in session restore (#12886) 2022-03-18 18:17:37 -07:00
Andrey Lushnikov
cfe92e1608
feat(test-runner): implement expect.poll (#12815)
This patch implements `expect.poll()` method that polls given
predicate until a given synchronous predicate completes.

Usage:

```js
// wait until page gets 3 frames.
await expect.poll(() => page.frames().length, {
  timeout: 1000,
  message: 'custom error message',
}).toBe(3);
```

Fixes #10235
2022-03-18 16:31:26 -07:00
Dmitry Gozman
009185bb89
fix(test runner): do not print fixture location without a separate timeout (#12894)
Otherwise, user randomly sees some "extend" calls that have no real meaning.
2022-03-18 16:09:41 -07:00
Dmitry Gozman
209bde5000
feat(test runner): descrbe.skip (#12865)
`describe.skip` declares a test group that is skipped.
2022-03-18 16:07:11 -07:00
Max Schmitt
dd32956ccc
chore: improve handling with missing xserver (#12724) 2022-03-18 22:39:11 +01:00
Max Schmitt
d795f5dd64
chore: print error if install-deps is used != ubuntu (#12877) 2022-03-18 19:13:11 +01:00
Yury Semikhatsky
a8d80621b2
feat(chromium): large file uploads (#12860) 2022-03-18 09:00:52 -07:00
Dmitry Gozman
3a009531b1
feat(hooks): add a step per hook (#12867)
It is now possible to see which hooks were run in the html report.
2022-03-17 19:33:01 -07:00
Pavel Feldman
c7d6f96328
chore: disambiguate internal flags (#12866) 2022-03-17 18:27:33 -07:00
Dmitry Gozman
25483452c0
feat(fixtures): per-fixture timeout (#12751)
By default, fixtures share timeout with the test they are instantiated for.
However, for more heavy fixtures, especially worker-scoped ones, it makes
sense to have a separate timeout.

This introduces `{ timeout: number }` option to the list of fixture options
that opts the fixture into a dedicated timeout rather than sharing it
with the test.
2022-03-17 09:36:03 -07:00
Benny Neugebauer
2e434f725b
chore: fix markdown links in NPM README's (#12833) 2022-03-17 15:28:57 +01:00
Henrik Storck
05387b7835
fix: fix folder traversal for isModule check (#12836) (#12837) 2022-03-16 15:52:39 -08:00
Max Schmitt
e231db1810
chore: restore expect.any()/expect.anything() (#12820) 2022-03-16 21:34:41 +01:00
Yury Semikhatsky
1284ab8101
feat(webkit): bump to 1617, freeze macOS 10.15 (#12790) 2022-03-15 16:09:56 -07:00
Dmitry Gozman
f8c4cb3d24
fix(screenshot): do not stall on hideHighlight (#12764) 2022-03-15 14:13:45 -07:00
Pavel Feldman
6b324d3780
chore(vue): allow adding events in jsx templates (#12746) 2022-03-15 13:02:10 -07:00
github-actions[bot]
08c29b305b
feat(chromium): roll to r980398 (#12757)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-14 18:51:46 -07:00
Andrey Lushnikov
88610c8b4c
fix: properly define apiName for web-first assertions (#12706)
Turns out relying on PWTRAP in stack is not reliable: depending on the
call structure, the stack might be cut unpredictably by Node.js.

This patch removes PWTRAP and instead plumbs explicit stack and
pre-set `apiName` all the way down to `wrapApiCall`.
2022-03-14 18:01:13 -07:00
Andrey Lushnikov
e3bd7ce119
fix(test-runner): resolve outputDir wrt rootDir (#12755)
Currently, running `npx playwright test` in a subfolder of your project
will result in a `test-results` folder created in your `cwd`.

This is unexpected; instead, we should always resolve all paths
against `rootDir` - directory that contains config.
2022-03-14 17:20:17 -07:00
Yury Semikhatsky
990224bde4
Revert "feat(webkit): bump to 1617 (#12738)" (#12760)
This reverts commit 77824ee19e.
2022-03-14 17:08:32 -07:00
Yury Semikhatsky
77824ee19e
feat(webkit): bump to 1617 (#12738) 2022-03-14 15:11:21 -07:00
Max Schmitt
01beb6310a
docs: mention locator.nth is zero based (#12750)
Co-authored-by: Pavel Feldman <pavel.feldman@gmail.com>
2022-03-14 21:06:44 +01:00
Dmitry Gozman
237954212c
Revert "feat(line reporter): show stats, handle tty" (#12735)
This reverts commit be817d1a53, PR #12695.
Reason: found issues with stdout messing with stats.
2022-03-14 10:37:43 -07:00
Pavel Feldman
3b0a5b4753
chore: mount should return locator pointing to the component element / fragment (#12718) 2022-03-13 21:26:13 -07:00
Pavel Feldman
25c0369eaf
chore: prepare to publish component packages (#12697) 2022-03-12 13:51:27 -08:00
Yury Semikhatsky
19de9cacc3
docs: delete verification guide (#12698) 2022-03-12 09:32:54 -08:00
Max Schmitt
adcd32fc6e
fix(expect): toHaveCSS with custom CSS properties (#12709) 2022-03-12 09:32:40 -08:00
github-actions[bot]
ffc8031bad
feat(chromium): roll to r980066 (#12705)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-12 09:07:57 +01:00
Andrey Lushnikov
ef4b34fb7a
feat(toHaveScreenshot): enhance messaging in case of failures (#12677)
This patch:
- adds call logs to track screenshot timeouts, e.g. due to
  waiting for web fonts
- makes sure all snapshot expectations have `.png` extension
- throws a polite error when given a buffer or a string instead of a
  page or a locator
- removes stray NL between error description and call log
- makes sure `apiName` is always correct (and adds a test for it)
2022-03-11 22:40:28 -08:00
Dmitry Gozman
be817d1a53
feat(line reporter): show stats, handle tty (#12695)
- Line reporter now shows stats in addition to the test name:
  ```log
  [chromium] › page/page-click-react.spec.ts:108:1 › should not retarget when element changes on hover
  23% [21/93] Passed: 17 Flaky: 0 Failed: 0 Skipped: 4 (7s)
  ```

- When connected to a TTY or with `env.PLAYWRIGHT_LIVE_TERMINAL`
set to anything but `'0'` or `'false'`, line reporter updates in place.

- When not connected to a TTY, line reporter prints an update
after each ~1% of tests done, so it never prints more than 100 lines.

- Updated tests to the golden style.
2022-03-11 18:19:33 -08:00
Pavel Feldman
e9fa098bf3
chore: add ct examples (#12693) 2022-03-11 15:46:11 -08:00
Andrey Lushnikov
95c774cf84
feat: support multiple screenshots in HTML report (#12577)
This patch adds support to multiple diffs. These are possible
due to soft assertions.

Drive-by: rename second screenshot in `toHaveScreenshot` failure when
re-generating expectations from "expected" to "previous".
2022-03-11 08:46:13 -08:00
Andrey Lushnikov
e3ab6388a9
feat(toHaveScreenshot): enable sensible defaults (#12675)
This patch:
- Enables configuration of certain defaults for some options of `expect.toHaveScreenshot` method via `TestProject.expect.toHaveScreenshot` property
- Sets sensible defaults for these options:
  * `fonts: "ready"`
  * `animations: "disabled"`
  * `size: "css"`
2022-03-11 08:45:36 -08:00
Pavel Feldman
af55f48754
chore: add experimental mount (#12657) 2022-03-11 08:00:46 -08:00
Ross Wollman
ebae5e76df
feat(test-runner): more default workers for M1 (#12660)
New default is based on the very (unscientific) output of repeated a few
times:

```
$ for i in `seq 5 13`; do time npm run ctest -- --reporter=line --workers=$i 'page/*' 'selector*' 'channels*' 'resource-timing*'; done
```
2022-03-11 02:12:07 -08:00
Andrey Lushnikov
b51157bdea
feat: bring back maxDiffPixels in toMatchSnapshot (#12627)
This patch reverts 2 commits that removed the feature from the method:
- "fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570)"
  commit b8af8458d6.
- "chore: remove `maxDiffPixels` from toMatchSnapshot (#12539)"
  commit a3dff45974.
2022-03-10 18:41:16 -08:00
Andrey Lushnikov
e83549e8a0
fix: support all commong screenshot options in toHaveScreenshot (#12670)
This patch adds support for all common options in
`expect.toHaveScreenshot`.
2022-03-10 18:36:20 -08:00
Andrey Lushnikov
65b9cba143
chore: follow-up to animations default option (#12669)
This is a follow-up to 42765804bc
that was landed without bots.

I ran the bots manually on Linux & Mac.
2022-03-10 17:26:50 -08:00
Andrey Lushnikov
689d8196e0
chore: follow-up to fix docs (#12668)
This is a follow-up to 49e66c7f08 that was landed without bots.

I ran bots manually on Mac & Linux.
2022-03-10 17:19:44 -08:00
Andrey Lushnikov
42765804bc
chore: add "allow" as a default value for animations. (#12663) 2022-03-10 17:15:36 -08:00
Andrey Lushnikov
49e66c7f08
feat(screenshot): introduce new "fonts" option for screenshots (#12661)
This option will wait for webfonts to load before taking screenshots.
2022-03-10 16:54:36 -08:00
Andrey Lushnikov
12d8a262be
feat: support screenshotsDir option (#12642)
The `screenshotsDir` option controls the expectation storage
for `toHaveScreenshot()` function.

The new expectation management for screenshots has the following
key properties:
- All screenshots are stored in a single folder called `screenshotsDir`.
- Screenshot names **do not** respect `snapshotDir` and `snapshotSuffix`
  configurations.
- `screenshotsDir` is configurable per project. This way a "smoke tests"
  project can re-use screenshots from "all tests" project.
- Host platform is a top-level folder.

For example, given the following config:

```js
// playwright.config.ts
module.exports = {
  projects: [
    { name: 'Mobile Safari' },
    { name: 'Desktop Chrome' },
  ],
};
```

And the following test structure:

```
smoke-tests/
└── basic.spec.ts
```

Will result in the following screenshots folder structure by default:

```
__screenshots__/
└── darwin/
    ├── Mobile Safari/
    │   └── smoke-tests/
    │       └── basic.spec.ts/
    │           └── screenshot-expectation.png
    └── Desktop Chrome/
        └── smoke-tests/
            └── basic.spec.ts/
                └── screenshot-expectation.png
```
2022-03-10 16:50:26 -08:00
Pavel Feldman
4d3d0e2bda
chore: enable ts-esm support by default (#12658) 2022-03-10 14:48:33 -08:00
Yury Semikhatsky
cf643ff04c
docs: remove unsupported permission "push" from docs (#12654) 2022-03-10 14:00:25 -08:00
Dmitry Gozman
a388bb2302
feat(screenshot): size:'css'|'device' option (#12634)
With this experimental option, screenshot dimensions are in CSS pixels,
not physical device pixels, effectively ignoring the device scale factor.
2022-03-10 13:07:10 -08:00
Max Schmitt
3f468abedd
fix(test-runner): ESM compatibly on Windows (#12615) 2022-03-10 19:27:25 +01:00
Andrey Lushnikov
75eef09c0d
feat: show expectation name as part of toHaveScreenshot title (#12612)
This patch adds snapshot file name as part of `toHaveScreenshot`
and `toMatchSnapshot` step title.
2022-03-09 20:09:45 -08:00
Yury Semikhatsky
d49843edaa
fix(firefox): add missing dependency on Ubuntu 18.04 (#12625) 2022-03-09 11:21:15 -08:00
Dmitry Gozman
92430cc56c
chore(fixtures): do not force-close contexts in beforeAll (#12416)
This now happens the same way as for the test, in the worker cleanup
when browser closes, which is reported as a part of the test.
2022-03-09 07:26:46 -08:00
Dmitry Gozman
e8ce5d0258
feat(test runner): on beforeAll failure, precisely skip the tests (#12417)
Previously, we used to skip all the tests from the same file when
any `beforeAll` fails in the file.

Now, we only skip the rest of the tests affected by this particular
`beforeAll` and continue with other tests in the new worker.
2022-03-08 20:29:31 -08:00
Dmitry Gozman
4a768294b4
chore: cleanup hooks notion from raw/html reporters (#12610) 2022-03-08 19:08:31 -08:00
Dmitry Gozman
e895bc2751
reland(test-runner): rely on test title paths instead of ordinal (#12611)
Fixes #11904

Co-authored-by: Andrey Lushnikov <lushnikov@chromium.org>
2022-03-08 19:06:25 -08:00
Dmitry Gozman
682eeb4ae0
reland(hooks): separate test timeout from beforeAll/afterAll timeouts (#12609)
This makes it possible to have longer `beforeAll`/`afterAll` and not
affect first/last test timeout.
2022-03-08 19:05:23 -08:00
Yury Semikhatsky
176846672f
docs: clarify multiple before/after hooks execution order (#12606) 2022-03-08 17:42:50 -08:00
Dmitry Gozman
62a032baa0
chore: remove env.PLAYWRIGHT_NO_LAYOUT_SHIFT_CHECK (#12605) 2022-03-08 16:42:39 -08:00
Dmitry Gozman
9cd704220c
reland(test runner): run hooks/modifiers as a part of the test (#12518)
Reland: worker.stop() before worker.run() was hanging because
`_runFinished` promise was not initially resolved.
---
This moves `beforeAll`, `afterAll` and some modifiers from running
as a separate entity into running inside a test.

Pros:
- All errors are reported as test errors.
- All artifacts are collected as test artifacts.
- Reporters support this out of the box.

Details:
- Each test computes the necessary hooks to run and runs them.
- Teardown is usually performed during the test (on test failure or worker stop).
- `skipRemaining` is added to `DonePayload` to preserve the behavior
  where `beforeAll` hook failure skips subsequent tests.
  This behavior can now be improved to only target tests affected by this hook.
2022-03-08 16:35:14 -08:00
Andrey Lushnikov
4bccf2f6aa
chore: cut v1.20 branch (#12593) 2022-03-08 14:01:20 -08:00
github-actions[bot]
04e03728b8
feat(chromium): roll to r978106 (#12585)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-03-08 21:05:56 +01:00
Andrey Lushnikov
497b51ad8c
fix(toHaveScreenshot): fix initial screenshot time (#12576)
Instead of being taken immediately, first screenshot was actually
taken after 1 second.
2022-03-08 09:30:14 -08:00
github-actions[bot]
18e6aa3f15
feat(firefox): roll to r1319 (#12587)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-08 09:19:00 -08:00
Andrey Lushnikov
b8af8458d6
fix: explicitly ignore maxDiffPixels in toMatchSnapshot (#12570)
Fixes #12564
2022-03-07 16:55:35 -08:00
Dmitry Gozman
d836ed41d3
feat(remote): send 'x-playwright-browser' header (#12556) 2022-03-07 10:30:53 -08:00
Siddharth Singha Roy
a2b3d4f570
feat(cli) : allow passing PlaywrightServer.startDefault parameters via cli (#12530) 2022-03-07 09:15:46 -08:00
github-actions[bot]
702536d962
feat(webkit): roll to r1616 (#12541)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Yury Semikhatsky <yurys@chromium.org>
2022-03-06 12:22:47 +01:00
Andrey Lushnikov
d7648d390c
fix(toHaveScreenshot): round ratio up (#12540)
This way the ratio value could be used right away in configuation.
2022-03-04 18:55:48 -08:00
Andrey Lushnikov
a3dff45974
chore: remove maxDiffPixels from toMatchSnapshot (#12539)
References #12441
2022-03-04 18:27:04 -08:00
Andrey Lushnikov
6dac01aec7
fix: implement log scale back-off for screenshots (#12504)
References https://github.com/microsoft/playwright/issues/12441
2022-03-04 18:17:57 -08:00
Andrey Lushnikov
4953fc4845
chore: introduce toHaveScreenshot configuration options (#12507)
References https://github.com/microsoft/playwright/issues/12441
2022-03-04 17:30:43 -08:00
github-actions[bot]
adb2847d84
feat(firefox): roll to r1318 (#12537)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-04 17:29:35 -08:00
Max Schmitt
5fd43edcbb
chore: fix android tests after #12220 (#12535) 2022-03-05 00:18:03 +01:00
Karan Shah
fd1a1a2b1c
feat(android): Adding custom port parameter to connect to different adb server port (#12220) 2022-03-04 20:27:25 +01:00
Yury Semikhatsky
50cc1641d1
fix(webkit): add libopengl0 to the native deps (#12526) 2022-03-04 11:13:34 -08:00
Andrey Lushnikov
b45c788a33
fix(disable-animations): rename boolean to enum (#12503)
Enums are more flexible in the long run since they let us easily
extend API.

References #12441
2022-03-04 11:02:59 -08:00
Andrey Lushnikov
1f5cfcaeec
fix(to-have-screenshot): show number of bad pixels in mismatched error (#12502)
Drive-by: do not show empty call log.

References #12441
2022-03-04 11:01:05 -08:00
github-actions[bot]
ab40d934ad
feat(chromium): roll to r976882 (#12516)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-04 14:48:25 +01:00
Basarat Ali Syed
dd83ece3cb
chore(test-runner): correct warning instruction for port reuse (#12479) 2022-03-04 10:14:49 +01:00
Andrey Lushnikov
279e579097
chore: address pixelCount and pixelRatio review comments (#12501)
- documentation fixes
- rename pixelCount to maxDiffPixels
- rename pixelRatio to maxDiffPixelRatio
2022-03-03 23:17:31 -08:00
github-actions[bot]
856ff5c685
feat(firefox-beta): roll to r1318 (#12478)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-03 08:41:23 -08:00
Max Schmitt
3db4b48bd3
fix(cli): fix wrong property for passing browser name (#12489) 2022-03-03 17:17:23 +01:00
Pavel Feldman
34bf0d4b87
feat(test-runner): allow grepping in project (#12469) 2022-03-02 15:02:35 -08:00
Max Schmitt
b2e3357613
chore: throw error if setCookies expires value is not valid (#12470) 2022-03-02 23:10:40 +01:00
Yury Semikhatsky
2d7ec26dc2
fix(fetch): send secure cookies for http://localhost requests (#12450) 2022-03-02 09:33:30 -08:00
Pavel Feldman
4b19d59ec5
feat(test): introduce fully parallel mode (#12446) 2022-03-01 18:12:21 -08:00
Pavel Feldman
61a6cdde70
feat(api): expose locator.highlight (#12420) 2022-03-01 13:56:21 -08:00
Pavel Feldman
b79bb32c82
chore: do not stall on actions when test timeout is 0 (#12418) 2022-03-01 13:43:38 -08:00
Pavel Feldman
a612a3526a
chore: auto-detect ts esm mode (#12292) 2022-03-01 12:56:26 -08:00
Max Schmitt
5b7db90cb6
chore: hide unsupported expect methods (#12403) 2022-03-01 20:04:34 +01:00
Pavel Feldman
96945ab0a2
chore: do not print empty attachments in terminal (#12419) 2022-03-01 09:11:53 -08:00
Max Schmitt
e0e6b66cbe
chore(android): align android context options with mixin (#12401) 2022-03-01 18:11:38 +01:00
Pavel Feldman
6a663ef54f
chore(test-runner): revert recent changes to fix tests (#12439)
* 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.
2022-03-01 09:11:17 -08:00
Max Schmitt
d2ae6a9db2
fix: isDisabled check with option/optgroup (#12437) 2022-03-01 18:10:16 +01:00
github-actions[bot]
5efd7fb356
feat(chromium): roll to r975608 (#12425)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-03-01 09:22:47 +01:00
Andrey Lushnikov
a0cf33bbb0
fix: beautiful toHaveScreenshot in tracing (#12422) 2022-02-28 23:30:00 -08:00
Andrey Lushnikov
d744a87aee
fix(test-runner): rely on test title paths instead of ordinal (#12414)
Fixes #11904
2022-02-28 15:40:23 -08:00
Dmitry Gozman
73dee69558
fix(hooks): separate test timeout from beforeAll/afterAll timeouts (#12413)
This makes it possible to have longer `beforeAll`/`afterAll` and not
affect first/last test timeout.
2022-02-28 15:09:04 -08:00
Mateusz Burzyński
eaa98ce53a
feat(keyboard): support simple copy-pasting using meta+c/v (#10828)
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>
2022-02-28 13:43:43 -08:00
Andrey Lushnikov
396d920145
feat(test-runner): implement expect(pageOrLocator).toHaveScreenshot (#12242)
Fixes #9938
2022-02-28 12:25:59 -08:00
Andrey Lushnikov
8d94ed134c
fix: add snapshots for page and elementHandle screenshots (#12411)
Fixes #12280
2022-02-28 11:52:54 -08:00
Dmitry Gozman
47045ba48d
chore(test runner): run hooks/modifiers as a part of the test (#12329)
chore(test runner): run hooks/modifiers as a part of the test

This moves `beforeAll`, `afterAll` and some modifiers from running
as a separate entity into running inside a test.

Pros:
- All errors are reported as test errors.
- All artifacts are collected as test artifacts.
- Reporters support this out of the box.

Details:
- Each test computes the necessary hooks to run and runs them.
- Teardown is usually performed during the test (on test failure or worker stop).
- `skipRemaining` is added to `DonePayload` to preserve the behavior
  where `beforeAll` hook failure skips subsequent tests.
  This behavior can now be improved to only target tests affected by this hook.
2022-02-28 11:42:47 -08:00
github-actions[bot]
80a38a39c2
feat(chromium): roll to r974924 (#12377)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-26 07:52:27 +01:00
Max Schmitt
41e9b36f63
fix: install-deps did not throw on non 0 exit code (#12375) 2022-02-26 00:45:27 +01:00
Dmitry Gozman
3c2bca2768
fix(test loader): implement tsconfig paths through resolveFilename (#12357)
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`.
2022-02-25 15:43:58 -08:00
nswbmw
b47c95c20c
feat: add iPhone 12 Mini (#11429)
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-02-25 12:15:58 +01:00
Max Schmitt
821a8e93c7
chore: do not double trim in trace viewer (#12338) 2022-02-24 21:55:50 +01:00
Dmitry Gozman
91672595f2
fix(reporters): normalize usage of isTTY, env.CI and debug env variables (#12295)
- `stdout.isTTY` controls whether list reporter updates lines or just adds them;
- `env.CI` is used in a few places to affect the defaults:
  - whether to open interactive html;
  - default reporter dot/line;
  - default terminal reporter added to non-terminal reporters;
- `env.PWTEST_SKIP_TEST_OUTPUT` is removed;
- `env.PW_TEST_DEBUG_REPORTERS` is introduced specifically for tests.
2022-02-24 12:39:28 -08:00
Max Schmitt
0b55950d6a
chore: fix Android tests (#12325) 2022-02-24 06:57:32 +01:00
Andrey Lushnikov
71edad327b
fix: tolerate EBUSY error when removing output directories (#12323)
- Previous attempt: https://github.com/microsoft/playwright/pull/12300
- Revert with reasoning: ebc52d10e4

Fixes #12106
2022-02-23 14:23:57 -08:00
Andrey Lushnikov
df7fbe7857
Revert "chore: best-effort cleanup for output folders that are mounted (#12300)" (#12321)
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
2022-02-23 14:10:11 -08:00
Andrey Lushnikov
5879c7f362
chore: refactor toMatchSnapshot once again (#12313)
Keep massaging code in preparation for `toHaveScreenshot`.

References #9938
2022-02-23 13:17:37 -08:00
Andrey Lushnikov
e5c9d1e39f
chore: best-effort cleanup for output folders that are mounted (#12300)
Fixes #12106
2022-02-23 12:55:41 -08:00
Dmitry Gozman
4399623f9f
chore(test runner): make timeout a separate error in TestInfo.errors (#12315)
This way we control the timeout error message from the runner,
so that later on we can differentiate between test timeout, fixture
timeout and hook timeout.
2022-02-23 12:32:12 -08:00
Dmitry Gozman
114edecd3a
fix(list mode): keep outputDir intact (#12291) 2022-02-22 12:50:26 -08:00
Ben Lu
f933f65d03
feat(html): put diff first in image comparison (#12254) 2022-02-22 11:29:58 -08:00
Max Schmitt
52932172e7
docs(python): fix set_viewport_size in emulation.md (#12271) 2022-02-22 20:15:46 +01:00
github-actions[bot]
cbe075135c
feat(chromium): roll to r973391 (#12279)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-22 11:33:25 +01:00
github-actions[bot]
222033d6b2
feat(chromium): roll to r972766 (#12248)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-21 11:30:30 +01:00
Pavel Feldman
b8cf5ac661
fix(electron): do not attach external debugger when running Electron tests (#12250) 2022-02-19 17:46:26 -08:00
Andrey Lushnikov
18fdf927b7
chore: simplify screenshot option handling (#12245)
#9938
2022-02-18 21:34:56 -08:00
Dmitry Gozman
d3c4323021
fix(test runner): improve error message for unexpected calls (#12240) 2022-02-18 18:25:18 -08:00
Dmitry Gozman
ee0dd6ec71
fix(test runner): trim full output path (#12239)
Previously, we only trimmed the "full title" component, but
we should also trim the "relative path" component.
2022-02-18 15:40:36 -08:00
Dmitry Gozman
a7ef1da5e9
fix(selenium): support MicrosoftEdge (#12235) 2022-02-18 14:44:15 -08:00
Andrey Lushnikov
0682672242
chore: move comparator logic to playwright-core (#12232)
This will enable implementation of `toHaveScreenshot` on the
server-side.

Drive-by: drop blink-diff

References #9938
2022-02-18 14:39:17 -08:00
Andrey Lushnikov
b9e86b79ee
chore: refactor toMatchSnapshot implementation (#12206)
This patch prepares for the `toHaveScreenshot` implementation
by splitting common parts from `toMatchSnapshot`.

Drive-by: fix default extension generation from `.bin` to `.dat`
for unknown buffers.
2022-02-18 11:21:58 -08:00
github-actions[bot]
0518176f4a
feat(chromium): roll to r969391 (#12228)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-18 18:54:58 +01:00
Dmitry Gozman
edac84d072
feat(remote): send browser/channel/headless in a header (#12205) 2022-02-18 07:54:33 -08:00
Dmitry Gozman
34eec7eae7
fix(webServer): route output through reporters (#12198) 2022-02-18 07:54:01 -08:00
Dmitry Gozman
15043801cb
chore: use transport for BrowserType.connect (#12196)
This gives us logging, ECONNRESET error handling and proper cleanup.
2022-02-17 20:48:14 -08:00
Andrey Lushnikov
a98babec69
feat(test-runner): introduce pixelCount and pixelRatio options (#12169)
This patch adds additional options to `toMatchSnapshot` method:
- `pixelCount` - acceptable number of pixels that differ to still
  consider images equal. Unset by default.
- `pixelRatio` - acceptable ratio of all image pixels (from 0 to 1) that differ to still
  consider images equal. Unset by default.

Fixes #12167, #10219
2022-02-17 15:44:03 -08:00
Andrey Lushnikov
c98d595bea
fix: support hiding caret in case of matching style rule (#12172) 2022-02-17 14:05:56 -08:00
Max Schmitt
21ae298015
fix(trace-viewer): don't crash when argument is null (#12186) 2022-02-17 22:12:42 +01:00
Max Schmitt
4115235f4d
feat(codegen): use web-first page assertions to match URL (#12177) 2022-02-17 20:52:35 +01:00
Max Schmitt
a667d94d45
chore(codegen): do not over-escape spaces (#12155) 2022-02-17 01:01:46 +01:00
Pavel Feldman
51344c6924
chore: parse-skip .tsx (#12143) 2022-02-16 15:45:35 -08:00
Andrey Lushnikov
086333cd60
feat(test-runner): support unnamed snapshots (#12161)
Fixes #9007
2022-02-16 14:22:01 -08:00
Max Schmitt
92045b7faf
feat(codgen): support radio buttons (#12157) 2022-02-16 19:10:00 +01:00
Dmitry Gozman
47cc7c4ae8
chore: refactor internal cli commands to use commander (#12146) 2022-02-16 09:54:12 -08:00
Yury Semikhatsky
7ee35ae30d
fix(html-report): open all test traces in one viewer (#12142) 2022-02-16 09:09:42 -08:00
Yury Semikhatsky
08fd8d0762
fix(tracing): do not capture iframes in head (#12126) 2022-02-16 09:09:15 -08:00
Pavel Feldman
d4deefbad3
feat(firefox): roll to r1317 (#12120) 2022-02-15 21:55:52 -08:00
pierscowburn
5db7ce5964
fix: propagate exit code in experimental mode (#12070)
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.
2022-02-15 13:10:35 -08:00
Andrey Lushnikov
e6d79a4f10
fix(docker): add missing dependency to the docker 1.19 (#12124)
The `libxtst6` is required in both amd64 and arm64.

Fixes #12075
2022-02-15 10:25:59 -08:00
Yury Semikhatsky
f15610b874
fix(fetch): always return non-empty body regardless of request method (#12102) 2022-02-15 09:06:21 -08:00
Andrey Lushnikov
363b8a6970
feat: support mask option in screenshot methods (#12072)
Fixes https://github.com/microsoft/playwright/issues/10162
2022-02-15 07:05:05 -08:00
Dmitry Gozman
5a0445b8da
feat(remote): let client enable/disable sock proxy (#12086) 2022-02-14 15:10:58 -08:00
Andrey Lushnikov
ef21ce3f56
feat(test-runner): filter out syntax error stack traces (#12095)
Filter out long stack traces from babel when it fails compilation
due to syntax error in test.
2022-02-14 14:33:14 -08:00
github-actions[bot]
6ff23fc446
feat(webkit): roll to r1611 (#12087)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-02-14 22:48:47 +01:00
Dmitry Gozman
9814c592d2
fix(test runner): shutdown redundant workers (#12062) 2022-02-14 10:57:15 -08:00
Andrey Lushnikov
6c89f160e8
fix(highlight): drive-by fixes to selector highlight (#12083) 2022-02-14 10:32:18 -08:00
Dmitry Gozman
fb00991a78
chore: intercept socks proxy in the driver (#12021) 2022-02-13 14:03:47 -08:00
Pavel Feldman
96b5831a49
chore: add support private methods in TS (#12051) 2022-02-11 14:46:49 -08:00
Dmitry Gozman
ccb09acdba
fix(remote): make playwright server work with firefox-beta (#12039)
It is not considered "channel", but rather a "tool".
2022-02-11 14:02:02 -08:00
Max Schmitt
7e7996a7b7
chore(dotnet): do not use global CLI and use ps1 instead (#12025)
Fixes https://github.com/microsoft/playwright-dotnet/issues/2005
2022-02-11 11:26:16 -08:00
Joel Einbinder
c6641321a0
chore: fix spelling error in comment (#12038) 2022-02-11 09:51:13 -08:00
Yury Semikhatsky
abd7084bcc
fix: match default font families in headless chromium (#11340) 2022-02-11 09:06:17 -08:00
Dmitry Gozman
d8db785c0a
fix(reporters): correctly handle missing stdout.columns (#12016)
When columns are not available, do not trim the output.
2022-02-11 08:33:56 -08:00
Pavel Feldman
da2cecbea0
chore: don't close page in generated test (#12022) 2022-02-11 08:11:24 -08:00
Pavel Feldman
5ab7bc3a59
chore: headless mode for codegen (#12020) 2022-02-10 21:23:16 -08:00
Dmitry Gozman
66b5cf5ae1
feat(remote): make PlaywrightServer work with browserType.connect (#11849)
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' });
```
2022-02-10 16:36:23 -08:00
Dmitry Gozman
2bc19ae076
chore: extract SocksProxy to a spearate file (#12011) 2022-02-10 13:04:19 -08:00
Pavel Feldman
ea590c6f67
fix(teardown): await teardown in failed test runs (#12012) 2022-02-10 12:44:42 -08:00
Ross Wollman
0d42c16a17
fix(test-runner): undefined body crash with manual attachments (#11995)
The new (as of 1.18) `async testInfo.attach(…)` API handles this
gracefully (and is part of the reason for the new API's existence).
However, for the foreseeable future, it's still possible to manually
push onto the attachments array where we can't validate the contents
until it's too late, so this change ensures more graceful handling in
that case.

Fixes #11565
2022-02-10 12:33:38 -08:00
Dmitry Gozman
9c66068971
fix(connect): make route.fulfill({ response }) work (#12006) 2022-02-10 12:05:04 -08:00
Pavel Feldman
fbc05b74a7
chore: revert "fix(test-runner): escape backslashes in win cli (#11763)" (#12004) 2022-02-10 07:02:37 -08:00
Mateusz Burzyński
b0cd5b1420
feat(mouse): set .buttons correctly for basic mouse commands in Chrome (#10698)
Co-authored-by: Andrey Lushnikov <aslushnikov@gmail.com>
2022-02-09 20:48:16 -08:00
Dmitry Gozman
1f6b84f445
fix(mac): avoid printing empty line to stderr on mac (#11991)
It turns out, `sw_vers` prints an empty stderr line and we inherit it.
2022-02-09 15:34:10 -08:00
Andrey Lushnikov
6904b3294e
fix(test-runner): fix browser initialization in test modifiers (#11984)
Fixes #11985
2022-02-09 15:30:14 -08:00
Dmitry Gozman
ae7c52154f
fix(fixtures): make sure connected browser respects context options (#11990)
Connected browser was wired up to the wrong browserType object.
2022-02-09 15:25:15 -08:00
Andrey Lushnikov
6f87955243
feat: introduce disableAnimations option for screenshots (#11870)
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
2022-02-09 12:52:11 -08:00
Darío Kondratiuk
48cc41f3e7
feat: add key support on react engine (#11970)
I've got [this question](https://stackoverflow.com/questions/71050193/react-locator-example/71052432#71052432) on StackOverflow. And although, in that case, the `key` was part of the `props` attributes. That might not always be true.

I am bringing this to the tell to see what you think about this.
I'm also fixing a typo :)
2022-02-09 11:33:15 -08:00
Andrey Lushnikov
1e1a6acaf7
fix: proper chrome-beta channel installation on MacOS (#11973)
chrome-beta installation on MacOS should download universal binaries.

The old download URL for chrome-beta was downloading Chrome Beta M96
2022-02-09 11:28:51 -08:00
Yury Semikhatsky
f2773fbb3a
fix: include call log into browerType.launchServer TimeoutError (#11956) 2022-02-09 09:54:16 -08:00
Yury Semikhatsky
706c897031
feat(fixtures): respect tracing config for APIRequestContext (#11954) 2022-02-09 08:54:09 -08:00
Pavel Feldman
e9e5de2d57
feat(debug): allow preprocessing JS scripts as well (#11953) 2022-02-09 07:14:11 -08:00
Dmitry Gozman
19368e93af
feat(test runner): support connectOptions (#11919)
This allows to specify `connectOptions` in the config that
switch built-in `browser` to be remotely connected.
2022-02-08 20:45:42 -08:00
Dmitry Gozman
5881a46ecf
fix(test runner): skip beforeAll/afterAll when all tests are skipped (#11952)
There is a corner case where tests were skipped like this:

```js
test.skip('title', () => {});
```
2022-02-08 16:36:30 -08:00
Andrey Lushnikov
3eba252f2e
chore: cut v1.19.0 (#11944) 2022-02-08 16:01:44 -08:00
Dmitry Gozman
e92caf01b3
fix(webServer): do not set baseURL equal to webServer.url (#11951) 2022-02-08 15:57:36 -08:00
Pavel Feldman
8dff2e35c8
chore: don't throw on no testDir (#11950) 2022-02-08 15:27:05 -08:00
Pavel Feldman
d5158e8d24
chore: revert source-map-support to 0.4.18 (#11945) 2022-02-08 14:50:20 -08:00
Pavel Feldman
4bcca2c87e
chore: add a parallel mode note (#11943) 2022-02-08 14:36:14 -08:00
Pavel Feldman
9ce8572c78
chore: don't run debugger on pause() (#11948) 2022-02-08 14:24:13 -08:00
Yury Semikhatsky
985f932033
chore(trace-viewer): introduce MultiTraceModel (#11922) 2022-02-08 12:27:29 -08:00
Pavel Feldman
1b3c7c03b6
chore: fix(stack): ignore stack frames inside whole core (#11935) 2022-02-08 10:33:50 -08:00
Pavel Feldman
9f35a97a55
chore(chrome): tolerate unknown target types (#11936) 2022-02-08 09:46:05 -08:00
Dmitry Gozman
8a5c93436d
fix(reporter): do not report parallel tests as slow (#11921) 2022-02-07 20:10:13 -08:00
Pavel Feldman
dbd124d84b
chore: disable page.pause() when JS debugger is attached (#11926) 2022-02-07 19:21:58 -08:00
Dmitry Gozman
7912c515a3
fix(fixtures): account for default options being undefined (#11916) 2022-02-07 17:11:36 -08:00
Yury Semikhatsky
1e00218ead
feat(tracing): suport loading multiple files in trace viewer (#11880) 2022-02-07 17:05:42 -08:00
Pavel Feldman
9116adc684
chore: allow opt-into the legacy global setup mode (#11888) 2022-02-07 10:41:56 -08:00
Pavel Feldman
c3c99a5f66
chore: shift left the inspector window. 2022-02-07 10:41:33 -08:00
Dmitry Gozman
f82e09be04
feat(codegen): generate locators and frame locators (#11873) 2022-02-04 19:27:45 -08:00
Yury Semikhatsky
46dfa45b4e
docs: fix parallel test docs build (#11877) 2022-02-04 16:44:04 -08:00
Yury Semikhatsky
afc4b505aa
docs: fix duplicate sections (#11874) 2022-02-04 13:50:46 -08:00
Dmitry Gozman
c45dacc834
feat(codegen): make selector generator strict (#11856)
This is required to migrate to locators.
2022-02-04 07:34:23 -08:00
Andrey Lushnikov
547a32885b
feat: hide blinking cursor when making screenshots (#11854)
References #9938
2022-02-03 21:44:23 -08:00
Dmitry Gozman
d9a8bb057d
fix(test-fail): allow unhandled expects in test.fail (#11850)
Previously, we would consider this a worker error, but
we make an exception for "expect()" calls.
2022-02-03 17:14:12 -08:00
Pavel Feldman
72424dc904
chore: allow setting reporter via env (#11848) 2022-02-03 16:10:39 -08:00
github-actions[bot]
f96b1dd43b
feat(webkit): roll to r1609 (#11824) 2022-02-03 08:20:39 -08:00
Pavel Feldman
1215057ca1
chore: use ipc transport for out-of-process driver (#11826) 2022-02-02 21:26:45 -08:00
Pavel Feldman
fdda759a9d
feat(parallel): allow setting enclosing scope parallel mode (#11822) 2022-02-02 20:44:11 -08:00
Andrey Lushnikov
ba0c7e679b
feat(test-runner): support expect.soft (#11800)
Soft expects will still fail the test, but will not abort it's execution. As a consequence of this:
-  `TestResult` now might have multiple errors, which is reflected with a new `testResult.erros: TestError[]` field.
- `TestInfo` now might have multiple errors as well, which is reflected with a new `testInfo.errors: TestError[]` field.

Fixes #7819
2022-02-02 18:33:51 -08:00
Dmitry Gozman
f587a43932
feat(locator): "has" option (#11411)
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`.
2022-02-02 16:55:50 -08:00
github-actions[bot]
fba523a9d0
feat(chromium): roll to r965416 (#11802)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Max Schmitt <max@schmitt.mx>
2022-02-02 11:39:10 +01:00
Max Schmitt
c752b28516
chore: pin production dependencies (#11793) 2022-02-02 11:14:41 +01:00
Andrey Lushnikov
b0daa7754f
feat: filter stack traces to exclude test runner frames (#11795)
Before:

```bash
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at Proxy.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/expect.ts:151:30)
        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
        at /Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:335:13
        at runNextTicks (node:internal/process/task_queues:61:5)
        at processImmediate (node:internal/timers:437:9)
        at TestInfoImpl._runFn (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:164:7)
        at WorkerRunner._runTestWithBeforeHooks (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:317:24)
        at TimeoutRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-core/src/utils/async.ts:48:14)
        at TestInfoImpl._runWithTimeout (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/testInfo.ts:151:7)
        at WorkerRunner._runTestOrAllHook (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:276:5)
        at WorkerRunner._runSuite (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:190:11)
        at WorkerRunner.run (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/workerRunner.ts:137:9)
        at process.<anonymous> (/Users/andreylushnikov/prog/playwright/packages/playwright-test/src/worker.ts:87:5)
```

after:

```
Running 1 test using 1 worker
  1) [chromium] › tests/example.spec.ts:3:1 › should work ==========================================

    Error: expect(received).toBe(expected) // Object.is equality

    Expected: 2
    Received: 1

      2 |
      3 | test('should work', async({page}) => {
    > 4 |   expect(1).toBe(2);
        |             ^
      5 | });
      6 |

        at /Users/andreylushnikov/tmp/tests/example.spec.ts:4:13
```
2022-02-01 18:40:44 -08:00
Pavel Feldman
ceb3027bdf
chore(test-runner): force colors in worker processes (#11799) 2022-02-01 17:29:15 -08:00
Pavel Feldman
6e2fcc4700
chore: do not expose suite load error (#11797) 2022-02-01 15:34:16 -08:00
Yury Semikhatsky
e7bd62f202
docs(electron): minimal version (#11792) 2022-02-01 14:45:30 -08:00
Pavel Feldman
f875ebe730
fix(test-runner): respect source maps when reporting test files (#11770) 2022-02-01 13:04:54 -08:00
Max Schmitt
028afb167b
chore: bump production dependencies (#11787) 2022-02-01 21:27:34 +01:00
Pavel Feldman
a3bc911a3d
fix(debug): don't apply infinite timeouts when using debugger (#11785) 2022-02-01 11:51:37 -08:00
Caio Agiani
b6b60decdf
fix: typos (#11789) 2022-02-01 11:09:41 -08:00
Pavel Feldman
3a5e8184b5
fix(html-reporter): open tests from required file (#11784) 2022-02-01 11:01:52 -08:00
Yury Semikhatsky
c2f6462a6b
fix(trace-viewer): info message for actions without snapshots (#11765) 2022-02-01 09:26:38 -08:00
Pavel Feldman
c82f2641d7
fet(list-files): report per-project test dir and filters (#11764) 2022-02-01 08:08:56 -08:00
Pavel Feldman
c5d852f1bb
fix(test-runner): escape backslashes in win cli (#11763) 2022-01-31 17:48:05 -08:00
Andrey Lushnikov
2336692e8a
feat: support clarification message for expect (#11735)
The clarification message is displayed in the HTML report as the name of the step:

![image](https://user-images.githubusercontent.com/746130/151852652-48194140-5ea4-439d-afee-12583a8caf71.png)

It is also shown in terminal output:

![image](https://user-images.githubusercontent.com/746130/151852666-5c956ef1-6e94-4bc2-8e55-b58688dfc7e0.png)

Fixes #7816
2022-01-31 17:14:59 -08:00
Pavel Feldman
2b55adaafa
feat(breaking): always report onBegin/onEnd, report file errors (#11758) 2022-01-31 17:09:04 -08:00
Dmitry Gozman
0b04c7d504
fix(drag&drop): relax layout shift logic when dropping (#11760)
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.
2022-01-31 16:21:35 -08:00
Yury Semikhatsky
129d9d3643
docs(tracing): clarify capture semantics (#11756) 2022-01-31 11:44:10 -08:00
github-actions[bot]
22989ffb98
feat(firefox-beta): roll to r1316 (#11675)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-01-31 19:06:09 +01:00
Andrey Lushnikov
3a4e506479
chore: extract SigIntWatcher (#11749)
This is to reduce the size of the long `_run` method in the `runner.ts`.
It also might come handy around the codebase.
2022-01-31 08:51:22 -08:00
Andrey Lushnikov
b58b004f0f
fix: run reporter.onEnd after webserver teardown (#11712)
Fixes #11647
2022-01-31 06:19:33 -08:00
Xiaoxing Ye
a35c249fdc
fix: quote path to prevent space issue (#11733)
Co-authored-by: Xiaoxing Ye <xiaoye@microsoft.com>
2022-01-29 09:56:58 -08:00
Dmitry Gozman
eeebcd53ae
chore(test runner): extract TestInfoImpl (#11725) 2022-01-28 17:39:42 -08:00
Yury Semikhatsky
401cd9c0ee
fix(fetch): do not throw on empty response body with br encoding (#11708) 2022-01-28 12:58:58 -08:00
Dmitry Gozman
30f3cbd6da
fix(fixtures): make sure defaultLaunchOptions are always there (#11713) 2022-01-28 10:51:55 -08:00
Yury Semikhatsky
84248f6e48
fix(webkit): handle will/didCheckPolicyForNavigation (#11631) 2022-01-27 14:58:43 -08:00
Yury Semikhatsky
480338d5f3
fix: create traces dir in /tmp instead of cwd (#11699) 2022-01-27 14:58:17 -08:00
Yury Semikhatsky
d305a2ab3f
fix: throw in route.continue if it is called twice (#11701) 2022-01-27 14:58:02 -08:00
Pavel Feldman
29a84b2df8
chore: allow pre-processing scripts (#11702) 2022-01-27 14:32:23 -08:00
Feng Yu
0698254253
docs: fix broken link (#11687)
fix #11680
2022-01-27 13:00:09 -08:00
Andrey Lushnikov
0606afb2e6
chore: rename env variables (#11661)
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
2022-01-27 09:06:43 -08:00
github-actions[bot]
d6e6d33db3
feat(firefox): roll to r1316 (#11676)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
2022-01-27 09:04:11 -08:00
Dmitry Gozman
b1fbc4fdbe
fix(test runner): resolve tsconfig for each file (#11662)
This allows us to properly handle path mappings
that are not too ambiguous.
2022-01-26 18:28:42 -08:00
divdavem
512a245f13
feat(test-runner): wait for a url before starting tests (#10138)
The webServer configuration in @playwright/test now accepts a url as an
alternative to a port number to wait for a url to return a 2xx status code.
2022-01-26 16:32:58 -08:00
hackerman
872a4be752
fix(server): handle = in cookie values correctly (#11613) 2022-01-26 11:27:43 -08:00
Dmitry Gozman
687a16b848
feat(locator): introduce locator.page() getter (#11630) 2022-01-26 07:58:58 -08:00
Dmitry Gozman
19820de7a9
fix(test runner): correctly save videos when running remotely (#11633) 2022-01-26 07:43:07 -08:00
Dmitry Gozman
4f42484c64
chore(test runner): simplify runTestWithBeforeHooks (#11629) 2022-01-25 16:46:50 -08:00
Andrey Lushnikov
6a7a2971f2
fix(chromium): close all javascript dialogs when closing context (#11614)
Fixes #11581
2022-01-25 13:52:18 -08:00
Yury Semikhatsky
62bf59e310
browser(webkit): removed unused will/didCheckNewWindowPolicy (#11626) 2022-01-25 12:30:11 -08:00
Puneet Agarwal
07e33e0c8c
Import remote client and server module (#11622) 2022-01-25 12:14:30 -08:00
Dmitry Gozman
800b813d4b
chore(test runner): prepare to per-fixture timeout (#11605)
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.
2022-01-25 11:22:28 -08:00
Andrey Lushnikov
3c27badd31
fix: bail early when installing channels on non-ubuntu (#11617)
Fixes #11615
2022-01-25 09:13:42 -08:00
Andrey Lushnikov
42876a0528
fix: support PWDEBUG=0 to disable debug (#11611)
Fixes #11606
2022-01-25 08:40:24 -08:00
Andrey Lushnikov
e10cb4a619
devops: fix Firefox on Ubuntu 20.04 aarch64 (#11602)
Turns out Firefox 96 now requires libxtst6 on Ubuntu 20.04 aarch64.
2022-01-24 16:20:28 -08:00
Ross Wollman
64e7557fb9
fix: falsey behavior in route.continue, page.post, testInfo.attach (#11421)
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.
2022-01-24 15:06:36 -08:00
Dmitry Gozman
a5bc2efc18
chore: followRedirects in PlaywrightClient (#11599) 2022-01-24 12:41:27 -08:00