mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: expect.toHaveScreenshot.animations types (#14387)
This makes the docs/types match the code which has already been released. Relevant code to traverse up from: -3e084829c0/packages/playwright-core/src/server/screenshotter.ts (L89)-3e084829c0/packages/playwright-core/src/server/screenshotter.ts (L118)Fixes #14385
This commit is contained in:
parent
19237c9490
commit
9b225f2ad4
@ -40,7 +40,7 @@ export default config;
|
||||
- `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.
|
||||
- `animations` ?<[ScreenshotAnimations]<"allow"|"disable">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disable"`.
|
||||
- `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.
|
||||
|
||||
@ -111,7 +111,7 @@ export default config;
|
||||
- `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.
|
||||
- `animations` ?<[ScreenshotAnimations]<"allow"|"disable">> See [`option: animations`] in [`method: Page.screenshot`]. Defaults to `"disable"`.
|
||||
- `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.
|
||||
|
||||
8
packages/playwright-test/types/test.d.ts
vendored
8
packages/playwright-test/types/test.d.ts
vendored
@ -508,9 +508,9 @@ interface TestConfig {
|
||||
|
||||
/**
|
||||
* See `animations` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults
|
||||
* to `"disable"`.
|
||||
* to `"disabled"`.
|
||||
*/
|
||||
animations?: "allow"|"disable";
|
||||
animations?: "allow"|"disabled";
|
||||
|
||||
/**
|
||||
* See `caret` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults to
|
||||
@ -4020,9 +4020,9 @@ interface TestProject {
|
||||
|
||||
/**
|
||||
* See `animations` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults
|
||||
* to `"disable"`.
|
||||
* to `"disabled"`.
|
||||
*/
|
||||
animations?: "allow"|"disable";
|
||||
animations?: "allow"|"disabled";
|
||||
|
||||
/**
|
||||
* See `caret` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults to
|
||||
|
||||
8
tests/config/experimental.d.ts
vendored
8
tests/config/experimental.d.ts
vendored
@ -16690,9 +16690,9 @@ interface TestConfig {
|
||||
|
||||
/**
|
||||
* See `animations` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults
|
||||
* to `"disable"`.
|
||||
* to `"disabled"`.
|
||||
*/
|
||||
animations?: "allow"|"disable";
|
||||
animations?: "allow"|"disabled";
|
||||
|
||||
/**
|
||||
* See `caret` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults to
|
||||
@ -20232,9 +20232,9 @@ interface TestProject {
|
||||
|
||||
/**
|
||||
* See `animations` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults
|
||||
* to `"disable"`.
|
||||
* to `"disabled"`.
|
||||
*/
|
||||
animations?: "allow"|"disable";
|
||||
animations?: "allow"|"disabled";
|
||||
|
||||
/**
|
||||
* See `caret` in [page.screenshot([options])](https://playwright.dev/docs/api/class-page#page-screenshot). Defaults to
|
||||
|
||||
@ -74,6 +74,42 @@ test('should disable animations by default', async ({ runInlineTest }, testInfo)
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
test.describe('expect config animations option', () => {
|
||||
test('disabled', async ({ runInlineTest }, testInfo) => {
|
||||
const cssTransitionURL = pathToFileURL(path.join(__dirname, '../assets/css-transition.html'));
|
||||
const result = await runInlineTest({
|
||||
...playwrightConfig({
|
||||
expect: { toHaveScreenshot: { animations: 'disabled' } },
|
||||
}),
|
||||
'a.spec.js': `
|
||||
pwt.test('is a test', async ({ page }) => {
|
||||
await page.goto('${cssTransitionURL}');
|
||||
await expect(page).toHaveScreenshot({ timeout: 2000 });
|
||||
});
|
||||
`
|
||||
}, { 'update-snapshots': true });
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
test('allow', async ({ runInlineTest }, testInfo) => {
|
||||
const cssTransitionURL = pathToFileURL(path.join(__dirname, '../assets/css-transition.html'));
|
||||
const result = await runInlineTest({
|
||||
...playwrightConfig({
|
||||
expect: { toHaveScreenshot: { animations: 'allow' } },
|
||||
}),
|
||||
'a.spec.js': `
|
||||
pwt.test('is a test', async ({ page }) => {
|
||||
await page.goto('${cssTransitionURL}');
|
||||
await expect(page).toHaveScreenshot({ timeout: 2000 });
|
||||
});
|
||||
`
|
||||
}, { 'update-snapshots': true });
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.output).toContain('is-a-test-1-diff.png');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
test('should fail with proper error when unsupported argument is given', async ({ runInlineTest }, testInfo) => {
|
||||
const cssTransitionURL = pathToFileURL(path.join(__dirname, '../assets/css-transition.html'));
|
||||
const result = await runInlineTest({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user