docs: fix toMatchSnapshot optional name usage (#13321)
This commit is contained in:
parent
ffa9ba4a7b
commit
cb4fba5e56
|
|
@ -19,6 +19,14 @@ Ensures that passed value, either a [string] or a [Buffer], matches the expected
|
||||||
// Basic usage.
|
// Basic usage.
|
||||||
expect(await page.screenshot()).toMatchSnapshot('landing-page.png');
|
expect(await page.screenshot()).toMatchSnapshot('landing-page.png');
|
||||||
|
|
||||||
|
// Basic usage and the file name is derived from the test name.
|
||||||
|
expect(await page.screenshot()).toMatchSnapshot();
|
||||||
|
|
||||||
|
// Pass options to customize the snapshot comparison and have a generated name.
|
||||||
|
expect(await page.screenshot()).toMatchSnapshot({
|
||||||
|
maxDiffPixels: 27, // allow no more than 27 different pixels.
|
||||||
|
});
|
||||||
|
|
||||||
// Configure image matching threshold.
|
// Configure image matching threshold.
|
||||||
expect(await page.screenshot()).toMatchSnapshot('landing-page.png', { threshold: 0.3 });
|
expect(await page.screenshot()).toMatchSnapshot('landing-page.png', { threshold: 0.3 });
|
||||||
|
|
||||||
|
|
@ -29,10 +37,10 @@ expect(await page.screenshot()).toMatchSnapshot(['landing', 'step3.png']);
|
||||||
|
|
||||||
Learn more about [visual comparisons](./test-snapshots.md).
|
Learn more about [visual comparisons](./test-snapshots.md).
|
||||||
|
|
||||||
### param: ScreenshotAssertions.toMatchSnapshot.name
|
### param: ScreenshotAssertions.toMatchSnapshot.nameOrOptions
|
||||||
- `name` <[string]|[Array]<[string]>>
|
- `nameOrOptions` <[string]|[Array]<[string]>|[Object]>
|
||||||
|
|
||||||
Snapshot name.
|
Optional snapshot name. If not passed, the test name and ordinals are used when called multiple times. Also passing the options here is supported.
|
||||||
|
|
||||||
### option: ScreenshotAssertions.toMatchSnapshot.maxDiffPixels = %%-assertions-max-diff-pixels-%%
|
### option: ScreenshotAssertions.toMatchSnapshot.maxDiffPixels = %%-assertions-max-diff-pixels-%%
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ title: "Release notes"
|
||||||
|
|
||||||
```js
|
```js
|
||||||
expect(await page.screenshot()).toMatchSnapshot({
|
expect(await page.screenshot()).toMatchSnapshot({
|
||||||
fullPage: true, // take a full page screenshot
|
|
||||||
maxDiffPixels: 27, // allow no more than 27 different pixels.
|
maxDiffPixels: 27, // allow no more than 27 different pixels.
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue