You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asserts that the target element matches the given [accessibility snapshot](../aria-snapshots.md).
2247
2247
2248
+
Snapshot is stored in a separate `.yml` file in a location configured by `expect.toMatchAriaSnapshot.pathTemplate` and/or `snapshotPathTemplate` properties in the configuration file.
This option configures a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: SnapshotAssertions.toMatchSnapshot#1`].
1761
+
This option configures a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`], [`method: LocatorAssertions.toMatchAriaSnapshot#2`] and [`method: SnapshotAssertions.toMatchSnapshot#1`].
1762
+
1763
+
You can configure templates for each assertion separately in [`property: TestConfig.expect`].
1762
1764
1763
1765
**Usage**
1764
1766
@@ -1767,7 +1769,19 @@ import { defineConfig } from '@playwright/test';
*`{arg}` - Relative snapshot path **without extension**. These come from the arguments passed to the `toHaveScreenshot()` and `toMatchSnapshot()` calls; if called without arguments, this will be an auto-generated snapshot name.
1815
+
*`{arg}` - Relative snapshot path **without extension**. This comes from the arguments passed to `toHaveScreenshot()`, `toMatchAriaSnapshot()` or `toMatchSnapshot()`; if called without arguments, this will be an auto-generated snapshot name.
1802
1816
* Value: `foo/bar/baz`
1803
-
*`{ext}` - snapshot extension (with dots)
1817
+
*`{ext}` - Snapshot extension (with the leading dot).
1804
1818
* Value: `.png`
1805
1819
*`{platform}` - The value of `process.platform`.
1806
1820
*`{projectName}` - Project's file-system-sanitized name, if any.
Copy file name to clipboardexpand all lines: docs/src/test-api/class-testconfig.md
+3
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,9 @@ export default defineConfig({
48
48
-`scale` ?<[ScreenshotScale]<"css"|"device">> See [`option: Page.screenshot.scale`] in [`method: Page.screenshot`]. Defaults to `"css"`.
49
49
-`stylePath` ?<[string]|[Array]<[string]>> See [`option: Page.screenshot.style`] in [`method: Page.screenshot`].
50
50
-`threshold` ?<[float]> 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`.
51
+
-`pathTemplate` ?<[string]> A template controlling location of the screenshots. See [`property: TestConfig.snapshotPathTemplate`] for details.
52
+
-`toMatchAriaSnapshot` ?<[Object]> Configuration for the [`method: LocatorAssertions.toMatchAriaSnapshot#2`] method.
53
+
-`pathTemplate` ?<[string]> A template controlling location of the aria snapshots. See [`property: TestConfig.snapshotPathTemplate`] for details.
51
54
-`toMatchSnapshot` ?<[Object]> Configuration for the [`method: SnapshotAssertions.toMatchSnapshot#1`] method.
52
55
-`maxDiffPixels` ?<[int]> An acceptable amount of pixels that could be different, unset by default.
53
56
-`maxDiffPixelRatio` ?<[float]> An acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by default.
Copy file name to clipboardexpand all lines: docs/src/test-api/class-testproject.md
+3
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,9 @@ export default defineConfig({
98
98
-`caret` ?<[ScreenshotCaret]<"hide"|"initial">> See [`option: Page.screenshot.caret`] in [`method: Page.screenshot`]. Defaults to `"hide"`.
99
99
-`scale` ?<[ScreenshotScale]<"css"|"device">> See [`option: Page.screenshot.scale`] in [`method: Page.screenshot`]. Defaults to `"css"`.
100
100
-`stylePath` ?<[string]|[Array]<[string]>> See [`option: Page.screenshot.style`] in [`method: Page.screenshot`].
101
+
-`pathTemplate` ?<[string]> A template controlling location of the screenshots. See [`property: TestProject.snapshotPathTemplate`] for details.
102
+
-`toMatchAriaSnapshot` ?<[Object]> Configuration for the [`method: LocatorAssertions.toMatchAriaSnapshot#2`] method.
103
+
-`pathTemplate` ?<[string]> A template controlling location of the aria snapshots. See [`property: TestProject.snapshotPathTemplate`] for details.
101
104
-`toMatchSnapshot` ?<[Object]> Configuration for the [`method: SnapshotAssertions.toMatchSnapshot#1`] method.
102
105
-`threshold` ?<[float]> 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`.
103
106
-`maxDiffPixels` ?<[int]> an acceptable amount of pixels that could be different, unset by default.
Copy file name to clipboardexpand all lines: docs/src/test-snapshots-js.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ The snapshot name `example-test-1-chromium-darwin.png` consists of a few parts:
48
48
49
49
-`chromium-darwin`- the browser name and the platform. Screenshots differ between browsers and platforms due to different rendering, fonts and more, so you will need different snapshots forthem. If you use multiple projects in your [configuration file](./test-configuration.md), project name will be used instead of`chromium`.
50
50
51
-
The snapshot name and path can be configured with [`snapshotPathTemplate`](./api/class-testproject#test-project-snapshot-path-template)in the playwright config.
51
+
The snapshot name and path can be configured with [`property: TestConfig.snapshotPathTemplate`] in the playwright config.
0 commit comments