Skip to content

Commit de374be

Browse files
feat(roll): roll to ToT Playwright (08-02-23) (microsoft#938)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7026a25 commit de374be

File tree

6 files changed

+87
-11
lines changed

6 files changed

+87
-11
lines changed

nodejs/docs/api/class-locatorassertions.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ Note that screenshot assertions only work with Playwright test runner.
454454
- `caret` "hide"|"initial" *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-1-option-caret"/><a href="#locator-assertions-to-have-screenshot-1-option-caret" class="list-anchor">#</a>
455455

456456
When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`, text caret behavior will not be changed. Defaults to `"hide"`.
457+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.31</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-1-option-comparator"/><a href="#locator-assertions-to-have-screenshot-1-option-comparator" class="list-anchor">#</a>
458+
459+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
457460
- `mask` [Array]<[Locator]> *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-1-option-mask"/><a href="#locator-assertions-to-have-screenshot-1-option-mask" class="list-anchor">#</a>
458461

459462
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box.
@@ -473,7 +476,7 @@ Note that screenshot assertions only work with Playwright test runner.
473476
Defaults to `"css"`.
474477
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-1-option-threshold"/><a href="#locator-assertions-to-have-screenshot-1-option-threshold" class="list-anchor">#</a>
475478

476-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
479+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
477480
- `timeout` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-1-option-timeout"/><a href="#locator-assertions-to-have-screenshot-1-option-timeout" class="list-anchor">#</a>
478481

479482
Time to retry the assertion for. Defaults to `timeout` in `TestConfig.expect`.
@@ -507,6 +510,9 @@ Note that screenshot assertions only work with Playwright test runner.
507510
- `caret` "hide"|"initial" *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-2-option-caret"/><a href="#locator-assertions-to-have-screenshot-2-option-caret" class="list-anchor">#</a>
508511

509512
When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`, text caret behavior will not be changed. Defaults to `"hide"`.
513+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.31</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-2-option-comparator"/><a href="#locator-assertions-to-have-screenshot-2-option-comparator" class="list-anchor">#</a>
514+
515+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
510516
- `mask` [Array]<[Locator]> *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-2-option-mask"/><a href="#locator-assertions-to-have-screenshot-2-option-mask" class="list-anchor">#</a>
511517

512518
Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink box `#FF00FF` that completely covers its bounding box.
@@ -526,7 +532,7 @@ Note that screenshot assertions only work with Playwright test runner.
526532
Defaults to `"css"`.
527533
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-2-option-threshold"/><a href="#locator-assertions-to-have-screenshot-2-option-threshold" class="list-anchor">#</a>
528534

529-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
535+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
530536
- `timeout` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="locator-assertions-to-have-screenshot-2-option-timeout"/><a href="#locator-assertions-to-have-screenshot-2-option-timeout" class="list-anchor">#</a>
531537

532538
Time to retry the assertion for. Defaults to `timeout` in `TestConfig.expect`.

nodejs/docs/api/class-pageassertions.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ Note that screenshot assertions only work with Playwright test runner.
6868
height of clipping area
6969

7070
An object which specifies clipping of the resulting image. Should have the following fields:
71+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.29</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-1-option-comparator"/><a href="#page-assertions-to-have-screenshot-1-option-comparator" class="list-anchor">#</a>
72+
73+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
7174
- `fullPage` [boolean] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-1-option-full-page"/><a href="#page-assertions-to-have-screenshot-1-option-full-page" class="list-anchor">#</a>
7275

7376
When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to `false`.
@@ -90,7 +93,7 @@ Note that screenshot assertions only work with Playwright test runner.
9093
Defaults to `"css"`.
9194
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-1-option-threshold"/><a href="#page-assertions-to-have-screenshot-1-option-threshold" class="list-anchor">#</a>
9295

93-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
96+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
9497
- `timeout` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-1-option-timeout"/><a href="#page-assertions-to-have-screenshot-1-option-timeout" class="list-anchor">#</a>
9598

9699
Time to retry the assertion for. Defaults to `timeout` in `TestConfig.expect`.
@@ -138,6 +141,9 @@ Note that screenshot assertions only work with Playwright test runner.
138141
height of clipping area
139142

140143
An object which specifies clipping of the resulting image. Should have the following fields:
144+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.29</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-2-option-comparator"/><a href="#page-assertions-to-have-screenshot-2-option-comparator" class="list-anchor">#</a>
145+
146+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
141147
- `fullPage` [boolean] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-2-option-full-page"/><a href="#page-assertions-to-have-screenshot-2-option-full-page" class="list-anchor">#</a>
142148

143149
When true, takes a screenshot of the full scrollable page, instead of the currently visible viewport. Defaults to `false`.
@@ -160,7 +166,7 @@ Note that screenshot assertions only work with Playwright test runner.
160166
Defaults to `"css"`.
161167
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-2-option-threshold"/><a href="#page-assertions-to-have-screenshot-2-option-threshold" class="list-anchor">#</a>
162168

163-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
169+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
164170
- `timeout` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="page-assertions-to-have-screenshot-2-option-timeout"/><a href="#page-assertions-to-have-screenshot-2-option-timeout" class="list-anchor">#</a>
165171

166172
Time to retry the assertion for. Defaults to `timeout` in `TestConfig.expect`.

nodejs/docs/api/class-snapshotassertions.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Note that matching snapshots only work with Playwright test runner.
5252

5353
Snapshot name.
5454
- `options` [Object] *(optional)*
55+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.29</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-1-option-comparator"/><a href="#snapshot-assertions-to-match-snapshot-1-option-comparator" class="list-anchor">#</a>
56+
57+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
5558
- `maxDiffPixelRatio` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-1-option-max-diff-pixel-ratio"/><a href="#snapshot-assertions-to-match-snapshot-1-option-max-diff-pixel-ratio" class="list-anchor">#</a>
5659

5760
An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`. Default is configurable with `TestConfig.expect`. Unset by default.
@@ -60,7 +63,7 @@ Note that matching snapshots only work with Playwright test runner.
6063
An acceptable amount of pixels that could be different. Default is configurable with `TestConfig.expect`. Unset by default.
6164
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-1-option-threshold"/><a href="#snapshot-assertions-to-match-snapshot-1-option-threshold" class="list-anchor">#</a>
6265

63-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
66+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
6467

6568
---
6669

@@ -94,6 +97,9 @@ Note that matching snapshots only work with Playwright test runner.
9497

9598
**Arguments**
9699
- `options` [Object] *(optional)*
100+
- `comparator` [string] *(optional)* <font size="2">Added in: v1.29</font><a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-2-option-comparator"/><a href="#snapshot-assertions-to-match-snapshot-2-option-comparator" class="list-anchor">#</a>
101+
102+
A comparator function to use when comparing images. Defaults to `"pixelmatch"`.
97103
- `maxDiffPixelRatio` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-2-option-max-diff-pixel-ratio"/><a href="#snapshot-assertions-to-match-snapshot-2-option-max-diff-pixel-ratio" class="list-anchor">#</a>
98104

99105
An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1`. Default is configurable with `TestConfig.expect`. Unset by default.
@@ -105,7 +111,7 @@ Note that matching snapshots only work with Playwright test runner.
105111
Snapshot name. If not passed, the test name and ordinals are used when called multiple times.
106112
- `threshold` [number] *(optional)*<a aria-hidden="true" tabindex="-1" class="list-anchor-link" id="snapshot-assertions-to-match-snapshot-2-option-threshold"/><a href="#snapshot-assertions-to-match-snapshot-2-option-threshold" class="list-anchor">#</a>
107113

108-
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`.
114+
An acceptable perceived color difference in the [YIQ color space](https://en.wikipedia.org/wiki/YIQ) between the same pixel in compared images, between zero (strict) and one (lax), default is configurable with `TestConfig.expect`. Defaults to `0.2`. This option is used by "pixelmatch" image comparator.
109115

110116

111117
[Accessibility]: /api/class-accessibility.mdx "Accessibility"

nodejs/docs/api/class-testconfig.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ module.exports = defineConfig({
118118

119119
Default timeout for async expect matchers in milliseconds, defaults to 5000ms.
120120
- `toHaveScreenshot` [Object] *(optional)*
121+
- `comparator` [string] *(optional)*
122+
123+
a comparator function to use, either `"pixelmatch"` or `"ssim-cie94"`. Defaults to `"pixelmatch"`.
121124
- `threshold` [number] *(optional)*
122125

123-
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
126+
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`. This option is used by `pixelmatch` image comparator.
124127
- `maxDiffPixels` [number] *(optional)*
125128

126129
an acceptable amount of pixels that could be different, unset by default.
@@ -139,9 +142,12 @@ module.exports = defineConfig({
139142

140143
Configuration for the [expect(page).toHaveScreenshot()](/api/class-pageassertions.mdx#page-assertions-to-have-screenshot-1) method.
141144
- `toMatchSnapshot` [Object] *(optional)*
145+
- `comparator` [string] *(optional)*
146+
147+
a comparator function to use, either `"pixelmatch"` or `"ssim-cie94"`. Defaults to `"pixelmatch"`.
142148
- `threshold` [number] *(optional)*
143149

144-
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
150+
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`. This option is used by `pixelmatch` image comparator.
145151
- `maxDiffPixels` [number] *(optional)*
146152

147153
an acceptable amount of pixels that could be different, unset by default.

nodejs/docs/api/class-testproject.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,12 @@ testProject.expect
181181

182182
Default timeout for async expect matchers in milliseconds, defaults to 5000ms.
183183
- `toHaveScreenshot` [Object] *(optional)*
184+
- `comparator` [string] *(optional)*
185+
186+
a comparator function to use, either `"pixelmatch"` or `"ssim-cie94"`. Defaults to `"pixelmatch"`.
184187
- `threshold` [number] *(optional)*
185188

186-
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
189+
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`. This option is used by `pixelmatch` image comparator.
187190
- `maxDiffPixels` [number] *(optional)*
188191

189192
an acceptable amount of pixels that could be different, unset by default.
@@ -202,9 +205,12 @@ testProject.expect
202205

203206
Configuration for the [expect(page).toHaveScreenshot()](/api/class-pageassertions.mdx#page-assertions-to-have-screenshot-1) method.
204207
- `toMatchSnapshot` [Object] *(optional)*
208+
- `comparator` [string] *(optional)*
209+
210+
a comparator function to use, either `"pixelmatch"` or `"ssim-cie94"`. Defaults to `"pixelmatch"`.
205211
- `threshold` [number] *(optional)*
206212

207-
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`.
213+
an acceptable perceived color difference between the same pixel in compared images, ranging from `0` (strict) and `1` (lax). `"pixelmatch"` comparator computes color difference in [YIQ color space](https://en.wikipedia.org/wiki/YIQ) and defaults `threshold` value to `0.2`. This option is used by `pixelmatch` image comparator.
208214
- `maxDiffPixels` [number] *(optional)*
209215

210216
an acceptable amount of pixels that could be different, unset by default.

nodejs/docs/test-reporters.mdx

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,53 @@ Or if there is a custom folder name:
457457
npx playwright show-report my-report
458458
```
459459

460-
> The `html` reporter currently does not support merging reports generated across multiple [`--shards`](./test-parallel.mdx#shard-tests-between-multiple-machines) into a single report. See [this](https://github.com/microsoft/playwright/issues/10437) issue for available third party solutions.
460+
#### Sharded report
461+
462+
When running tests on [multiple shards](./test-parallel.mdx#shard-tests-between-multiple-machines), the `html` reporter can automatically show test results from all shards in one page when configured with `sharded: true`.
463+
464+
<Tabs
465+
groupId="js-flavor"
466+
defaultValue="ts"
467+
values={[
468+
{label: 'TypeScript', value: 'ts'},
469+
{label: 'JavaScript', value: 'js'}
470+
]
471+
}>
472+
<TabItem value="ts">
473+
474+
```js
475+
// playwright.config.ts
476+
import { defineConfig } from '@playwright/test';
477+
478+
export default defineConfig({
479+
reporter: [['html', { sharded: true }]],
480+
});
481+
```
482+
483+
</TabItem>
484+
<TabItem value="js">
485+
486+
```js
487+
// playwright.config.js
488+
// @ts-check
489+
490+
const { defineConfig } = require('@playwright/test');
491+
492+
module.exports = defineConfig({
493+
reporter: [['html', { sharded: true }]],
494+
});
495+
```
496+
497+
</TabItem>
498+
</Tabs>
499+
500+
You can use sharded html report combined with a file hosting that allows serving html files.
501+
502+
In your CI recipe, after running tests in each shard, upload all files from `playwright-report` directory to the **same location**. After that you can open `index.html` from the uploaded location directly in the browser.
503+
504+
:::note
505+
The `html` report for each shard consists of `index.html` and a data file named like `report-003-of-100.zip`. It's ok to overwrite `index.html` with one another when copying sharded reports to a single directory.
506+
:::
461507

462508
### JSON reporter
463509

0 commit comments

Comments
 (0)