chore: rename ScreenshotAssertions to SnapshotAssertions (#19150)

This commit is contained in:
Pavel Feldman 2022-11-29 16:57:03 -08:00 committed by GitHub
parent c9ec8b3e55
commit 89bdaf2441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 25 deletions

View file

@ -1,4 +1,4 @@
# class: ScreenshotAssertions # class: SnapshotAssertions
* since: v1.20 * since: v1.20
* langs: js * langs: js
@ -9,7 +9,7 @@ expected values stored in files.
expect(screenshot).toMatchSnapshot('landing-page.png'); expect(screenshot).toMatchSnapshot('landing-page.png');
``` ```
## method: ScreenshotAssertions.toMatchSnapshot#1 ## method: SnapshotAssertions.toMatchSnapshot#1
* since: v1.22 * since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory. 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. Note that matching snapshots only work with Playwright test runner.
### param: ScreenshotAssertions.toMatchSnapshot#1.name ### param: SnapshotAssertions.toMatchSnapshot#1.name
* since: v1.22 * since: v1.22
- `name` <[string]|[Array]<[string]>> - `name` <[string]|[Array]<[string]>>
Snapshot name. Snapshot name.
### option: ScreenshotAssertions.toMatchSnapshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%% ### option: SnapshotAssertions.toMatchSnapshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
* since: v1.22 * 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 * since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#1.threshold = %%-assertions-threshold-%% ### option: SnapshotAssertions.toMatchSnapshot#1.threshold = %%-assertions-threshold-%%
* since: v1.22 * since: v1.22
## method: ScreenshotAssertions.toMatchSnapshot#2 ## method: SnapshotAssertions.toMatchSnapshot#2
* since: v1.22 * since: v1.22
Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test snapshots directory. 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. 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 * 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 * since: v1.22
### option: ScreenshotAssertions.toMatchSnapshot#2.name ### option: SnapshotAssertions.toMatchSnapshot#2.name
* since: v1.22 * since: v1.22
- `name` <[string]|[Array]<[string]>> - `name` <[string]|[Array]<[string]>>
Snapshot name. If not passed, the test name and ordinals are used when called multiple times. 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 * since: v1.22

View file

@ -1359,7 +1359,7 @@ Allows locating elements by their title. For example, this method will find the
- `type` ?<[string]> - `type` ?<[string]>
* langs: js * 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 ```js tab=js-ts
// playwright.config.ts // playwright.config.ts

View file

@ -37,7 +37,7 @@ toc_max_heading_level: 2
test('runs second', async ({ page }) => {}); 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 ```js
// playwright.config.ts // 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 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 ## Version 1.21

View file

@ -45,7 +45,7 @@ export default config;
- `animations` ?<[ScreenshotAnimations]<"allow"|"disabled">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disabled"`. - `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"`. - `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"`. - `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`. - `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. - `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. - `maxDiffPixelRatio` ?<[float]> an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by default.

View file

@ -116,7 +116,7 @@ export default config;
- `animations` ?<[ScreenshotAnimations]<"allow"|"disabled">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disabled"`. - `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"`. - `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"`. - `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`. - `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. - `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. - `maxDiffPixelRatio` ?<[float]> an acceptable ratio of pixels that are different to the total amount of pixels, between `0` and `1` , unset by default.

View file

@ -568,7 +568,7 @@ interface TestConfig {
/** /**
* Configuration for the * 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. * method.
*/ */
toMatchSnapshot?: { toMatchSnapshot?: {
@ -787,7 +787,7 @@ interface TestConfig {
* This option configures a template controlling location of snapshots generated by * 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) * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
* and * 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 * ```js
* // playwright.config.ts * // playwright.config.ts
@ -3320,7 +3320,7 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
* If the promise is fulfilled the assertion fails. * If the promise is fulfilled the assertion fails.
*/ */
rejects: MakeMatchers<Promise<R>, Awaited<T>>; rejects: MakeMatchers<Promise<R>, Awaited<T>>;
} & ScreenshotAssertions & } & SnapshotAssertions &
ExtraMatchers<T, Page, PageAssertions> & ExtraMatchers<T, Page, PageAssertions> &
ExtraMatchers<T, Locator, LocatorAssertions> & ExtraMatchers<T, Locator, LocatorAssertions> &
ExtraMatchers<T, APIResponse, APIResponseAssertions>; 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 * Ensures that passed value, either a [string] or a [Buffer], matches the expected snapshot stored in the test
* snapshots directory. * snapshots directory.
@ -4615,7 +4615,7 @@ interface TestProject {
/** /**
* Configuration for the * 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. * method.
*/ */
toMatchSnapshot?: { toMatchSnapshot?: {
@ -4700,7 +4700,7 @@ interface TestProject {
* This option configures a template controlling location of snapshots generated by * 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) * [pageAssertions.toHaveScreenshot(name[, options])](https://playwright.dev/docs/api/class-pageassertions#page-assertions-to-have-screenshot-1)
* and * 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 * ```js
* // playwright.config.ts * // playwright.config.ts

View file

@ -22,7 +22,7 @@ const path = require('path');
/** @typedef {import('../../markdown').MarkdownNode} MarkdownNode */ /** @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) { module.exports = function lint(documentation, jsSources, apiFileName) {
const errors = []; const errors = [];

View file

@ -521,7 +521,7 @@ class TypesGenerator {
const coreDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api')); 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 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 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 * @param {boolean} includeExperimental

View file

@ -302,7 +302,7 @@ type MakeMatchers<R, T> = BaseMatchers<R, T> & {
* If the promise is fulfilled the assertion fails. * If the promise is fulfilled the assertion fails.
*/ */
rejects: MakeMatchers<Promise<R>, Awaited<T>>; rejects: MakeMatchers<Promise<R>, Awaited<T>>;
} & ScreenshotAssertions & } & SnapshotAssertions &
ExtraMatchers<T, Page, PageAssertions> & ExtraMatchers<T, Page, PageAssertions> &
ExtraMatchers<T, Locator, LocatorAssertions> & ExtraMatchers<T, Locator, LocatorAssertions> &
ExtraMatchers<T, APIResponse, APIResponseAssertions>; ExtraMatchers<T, APIResponse, APIResponseAssertions>;