Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: rename ScreenshotAssertions to SnapshotAssertions (#19150)

Pavel Feldman89bdaf24418d
diff --git a/docs/src/api/class-screenshotassertions.md b/docs/src/api/class-snapshotassertions.md
similarity index 72%
rename from docs/src/api/class-screenshotassertions.md
rename to docs/src/api/class-snapshotassertions.md
index f00f70000d..a61a4752b1 100644
--- a/docs/src/api/class-screenshotassertions.md
+++ b/docs/src/api/class-snapshotassertions.md
@@ -1,4 +1,4 @@
-# class: ScreenshotAssertions
+# class: SnapshotAssertions
* since: v1.20
* langs: js
@@ -9,7 +9,7 @@ expected values stored in files.
expect(screenshot).toMatchSnapshot('landing-page.png');
```
-## method: ScreenshotAssertions.toMatchSnapshot#1
+## method: SnapshotAssertions.toMatchSnapshot#1
* since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory.
@@ -37,22 +37,22 @@ Learn more about [visual comparisons](../test-snapshots.md).
Note that matching snapshots only work with Playwright test runner.
-### param: ScreenshotAssertions.toMatchSnapshot#1.name
+### param: SnapshotAssertions.toMatchSnapshot#1.name
* since: v1.22
- `name` <[string]|[Array]<[string]>>
Snapshot name.
-### option: ScreenshotAssertions.toMatchSnapshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
+### option: SnapshotAssertions.toMatchSnapshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22
-### option: ScreenshotAssertions.toMatchSnapshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
+### option: SnapshotAssertions.toMatchSnapshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.22
-### option: ScreenshotAssertions.toMatchSnapshot#1.threshold = %%-assertions-threshold-%%
+### option: SnapshotAssertions.toMatchSnapshot#1.threshold = %%-assertions-threshold-%%
* since: v1.22
-## method: ScreenshotAssertions.toMatchSnapshot#2
+## method: SnapshotAssertions.toMatchSnapshot#2
* since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory.
@@ -79,17 +79,17 @@ Learn more about [visual comparisons](../test-snapshots.md).
Note that matching snapshots only work with Playwright test runner.
-### option: ScreenshotAssertions.toMatchSnapshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
+### option: SnapshotAssertions.toMatchSnapshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22
-### option: ScreenshotAssertions.toMatchSnapshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
+### option: SnapshotAssertions.toMatchSnapshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
* since: v1.22
-### option: ScreenshotAssertions.toMatchSnapshot#2.name
+### option: SnapshotAssertions.toMatchSnapshot#2.name
* since: v1.22
- `name` <[string]|[Array]<[string]>>
Snapshot name. If not passed, the test name and ordinals are used when called multiple times.
-### option: ScreenshotAssertions.toMatchSnapshot#2.threshold = %%-assertions-threshold-%%
+### option: SnapshotAssertions.toMatchSnapshot#2.threshold = %%-assertions-threshold-%%
* since: v1.22
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index 8fff325deb..e74d4847d1 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -1359,7 +1359,7 @@ Allows locating elements by their title. For example, this method will find the
- `type` ?<[string]>
* langs: js
-This option configures a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: ScreenshotAssertions.toMatchSnapshot#1`].
+This option configures a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: SnapshotAssertions.toMatchSnapshot#1`].
```js tab=js-ts
// playwright.config.ts
diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md
index 233c29d67a..e03e67b82c 100644
--- a/docs/src/release-notes-js.md
+++ b/docs/src/release-notes-js.md
@@ -37,7 +37,7 @@ toc_max_heading_level: 2
test('runs second', async ({ page }) => {});
```
-* Use [`property: TestProject.snapshotPathTemplate`] and [`property: TestConfig.snapshotPathTemplate`] to configure a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: ScreenshotAssertions.toMatchSnapshot#1`].
+* Use [`property: TestProject.snapshotPathTemplate`] and [`property: TestConfig.snapshotPathTemplate`] to configure a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: SnapshotAssertions.toMatchSnapshot#1`].
```js
// playwright.config.ts
@@ -550,7 +550,7 @@ WebServer is now considered "ready" if request to the specified port has any of
```
The new [`method: PageAssertions.toHaveScreenshot#1`] saves screenshots at the same
- location as [`method: ScreenshotAssertions.toMatchSnapshot#1`].
+ location as [`method: SnapshotAssertions.toMatchSnapshot#1`].
## Version 1.21
diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md
index 1ff4091afc..bcf5c05e43 100644
--- a/docs/src/test-api/class-testconfig.md
+++ b/docs/src/test-api/class-testconfig.md
@@ -45,7 +45,7 @@ export default config;
- `animations` ?<[ScreenshotAnimations]<"allow"|"disabled">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disabled"`.
- `caret` ?<[ScreenshotCaret]<"hide"|"initial">> See [`option: caret`] in [`method: Page.screenshot`]. Defaults to `"hide"`.
- `scale` ?<[ScreenshotScale]<"css"|"device">> See [`option: scale`] in [`method: Page.screenshot`]. Defaults to `"css"`.
- - `toMatchSnapshot` ?<[Object]> Configuration for the [`method: ScreenshotAssertions.toMatchSnapshot#1`] method.
+ - `toMatchSnapshot` ?<[Object]> Configuration for the [`method: SnapshotAssertions.toMatchSnapshot#1`] method.
- `threshold` ?<[float]> 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). Defaults to `0.2`.
- `maxDiffPixels` ?<[int]> an acceptable amount of pixels that could be different, unset by default.
- `maxDiffPixelRatio` ?<[float]> an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by default.
diff --git a/docs/src/test-api/class-testproject.md b/docs/src/test-api/class-testproject.md
index cb6aea3618..0515b9ed4e 100644
--- a/docs/src/test-api/class-testproject.md
+++ b/docs/src/test-api/class-testproject.md
@@ -116,7 +116,7 @@ export default config;
- `animations` ?<[ScreenshotAnimations]<"allow"|"disabled">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disabled"`.
- `caret` ?<[ScreenshotCaret]<"hide"|"initial">> See [`option: caret`] in [`method: Page.screenshot`]. Defaults to `"hide"`.
- `scale` ?<[ScreenshotScale]<"css"|"device">> See [`option: scale`] in [`method: Page.screenshot`]. Defaults to `"css"`.
- - `toMatchSnapshot` ?<[Object]> Configuration for the [`method: ScreenshotAssertions.toMatchSnapshot#1`] method.
+ - `toMatchSnapshot` ?<[Object]> Configuration for the [`method: SnapshotAssertions.toMatchSnapshot#1`] method.
- `threshold` ?<[float]> 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). Defaults to `0.2`.
- `maxDiffPixels` ?<[int]> an acceptable amount of pixels that could be different, unset by default.
- `maxDiffPixelRatio` ?<[float]> an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by default.
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index 7b7242f5b0..7917badbd3 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -568,7 +568,7 @@ interface TestConfig {
/**
* Configuration for the
- * [screenshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-screenshotassertions#screenshot-assertions-to-match-snapshot-1)
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
* method.
*/
toMatchSnapshot?: {
@@ -787,7 +787,7 @@ interface TestConfig {
* This option configures a template controlling location of snapshots generated by
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
* and
- * [screenshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-screenshotassertions#screenshot-assertions-to-match-snapshot-1).
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
*
* ```js
* // playwright.config.ts
@@ -3320,7 +3320,7 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
* If the promise is fulfilled the assertion fails.
*/
rejects: MakeMatchers<Promise<R>, Awaited<T>>;
- } & ScreenshotAssertions &
+ } & SnapshotAssertions &
ExtraMatchers<T, Page, PageAssertions> &
ExtraMatchers<T, Locator, LocatorAssertions> &
ExtraMatchers<T, APIResponse, APIResponseAssertions>;
@@ -4373,7 +4373,7 @@ interface PageAssertions {
* ```
*
*/
-interface ScreenshotAssertions {
+interface SnapshotAssertions {
/**
* Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
* snapshots directory.
@@ -4615,7 +4615,7 @@ interface TestProject {
/**
* Configuration for the
- * [screenshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-screenshotassertions#screenshot-assertions-to-match-snapshot-1)
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1)
* method.
*/
toMatchSnapshot?: {
@@ -4700,7 +4700,7 @@ interface TestProject {
* This option configures a template controlling location of snapshots generated by
* [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
* and
- * [screenshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-screenshotassertions#screenshot-assertions-to-match-snapshot-1).
+ * [snapshotAssertions.toMatchSnapshot(name[, options])](https://playwright.dev/docs/api/class-snapshotassertions#snapshot-assertions-to-match-snapshot-1).
*
* ```js
* // playwright.config.ts
diff --git a/utils/doclint/missingDocs.js b/utils/doclint/missingDocs.js
index d014a8888a..7ea77b3afd 100644
--- a/utils/doclint/missingDocs.js
+++ b/utils/doclint/missingDocs.js
@@ -22,7 +22,7 @@ const path = require('path');
/** @typedef {import('../../markdown').MarkdownNode} MarkdownNode */
-const IGNORE_CLASSES = ['PlaywrightAssertions', 'LocatorAssertions', 'PageAssertions', 'APIResponseAssertions', 'ScreenshotAssertions'];
+const IGNORE_CLASSES = ['PlaywrightAssertions', 'LocatorAssertions', 'PageAssertions', 'APIResponseAssertions', 'SnapshotAssertions'];
module.exports = function lint(documentation, jsSources, apiFileName) {
const errors = [];
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index 6752630dfc..3104e2a49f 100644
--- a/utils/generate_types/index.js
+++ b/utils/generate_types/index.js
@@ -521,7 +521,7 @@ class TypesGenerator {
const coreDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api'));
const testDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-api'), path.join(PROJECT_DIR, 'docs', 'src', 'api', 'params.md'));
const reporterDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-reporter-api'));
- const assertionClasses = new Set(['LocatorAssertions', 'PageAssertions', 'APIResponseAssertions', 'ScreenshotAssertions', 'PlaywrightAssertions']);
+ const assertionClasses = new Set(['LocatorAssertions', 'PageAssertions', 'APIResponseAssertions', 'SnapshotAssertions', 'PlaywrightAssertions']);
/**
* @param {boolean} includeExperimental
diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts
index ad666c606a..65813d0762 100644
--- a/utils/generate_types/overrides-test.d.ts
+++ b/utils/generate_types/overrides-test.d.ts
@@ -302,7 +302,7 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
* If the promise is fulfilled the assertion fails.
*/
rejects: MakeMatchers<Promise<R>, Awaited<T>>;
- } & ScreenshotAssertions &
+ } & SnapshotAssertions &
ExtraMatchers<T, Page, PageAssertions> &
ExtraMatchers<T, Locator, LocatorAssertions> &
ExtraMatchers<T, APIResponse, APIResponseAssertions>;