Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: expose project.ignoreSnapshots (#38974)
Pavel Feldmane01a5b1d59f4
diff --git a/docs/src/test-api/class-fullproject.md b/docs/src/test-api/class-fullproject.mdindex 682f9bb672..6946eb20c0 100644--- a/docs/src/test-api/class-fullproject.md+++ b/docs/src/test-api/class-fullproject.md@@ -22,6 +22,12 @@ See [`property: TestProject.grep`].See [`property: TestProject.grepInvert`].+## property: FullProject.ignoreSnapshots+* since: v1.59+- type: <[boolean]>++See [`property: TestProject.ignoreSnapshots`].+## property: FullProject.metadata* since: v1.10- type: <[Metadata]>diff --git a/packages/playwright/src/common/config.ts b/packages/playwright/src/common/config.tsindex 82d88aafed..27ea206171 100644--- a/packages/playwright/src/common/config.ts+++ b/packages/playwright/src/common/config.ts@@ -172,7 +172,6 @@ export class FullProjectInternal {readonly expect: Project['expect'];readonly respectGitIgnore: boolean;readonly snapshotPathTemplate: string | undefined;- readonly ignoreSnapshots: boolean;readonly workers: number | undefined;id = '';deps: FullProjectInternal[] = [];@@ -201,6 +200,7 @@ export class FullProjectInternal {use: mergeObjects(config.use, projectConfig.use, configCLIOverrides.use),dependencies: projectConfig.dependencies || [],teardown: projectConfig.teardown,+ ignoreSnapshots: takeFirst(configCLIOverrides.ignoreSnapshots, projectConfig.ignoreSnapshots, config.ignoreSnapshots, false),};this.fullyParallel = takeFirst(configCLIOverrides.fullyParallel, projectConfig.fullyParallel, config.fullyParallel, undefined);this.expect = takeFirst(projectConfig.expect, config.expect, {});@@ -209,7 +209,6 @@ export class FullProjectInternal {this.expect.toHaveScreenshot.stylePath = stylePaths.map(stylePath => path.resolve(configDir, stylePath));}this.respectGitIgnore = takeFirst(projectConfig.respectGitIgnore, config.respectGitIgnore, !projectConfig.testDir && !config.testDir);- this.ignoreSnapshots = takeFirst(configCLIOverrides.ignoreSnapshots, projectConfig.ignoreSnapshots, config.ignoreSnapshots, false);this.workers = projectConfig.workers ? resolveWorkers(projectConfig.workers) : undefined;if (configCLIOverrides.debug && this.workers)this.workers = 1;diff --git a/packages/playwright/src/isomorphic/teleReceiver.ts b/packages/playwright/src/isomorphic/teleReceiver.tsindex b4829257f8..27b48dc9a0 100644--- a/packages/playwright/src/isomorphic/teleReceiver.ts+++ b/packages/playwright/src/isomorphic/teleReceiver.ts@@ -56,6 +56,7 @@ export type JsonProject = {testMatch: JsonPattern[];timeout: number;use: { [key: string]: any };+ ignoreSnapshots?: boolean;};export type JsonSuite = {@@ -482,6 +483,7 @@ export class TeleReporterReceiver {dependencies: project.dependencies,teardown: project.teardown,snapshotDir: this._absolutePath(project.snapshotDir),+ ignoreSnapshots: project.ignoreSnapshots ?? false,use: project.use,};}diff --git a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts b/packages/playwright/src/matchers/toMatchAriaSnapshot.tsindex 1f11d8ee3f..15e828f70b 100644--- a/packages/playwright/src/matchers/toMatchAriaSnapshot.ts+++ b/packages/playwright/src/matchers/toMatchAriaSnapshot.ts@@ -46,7 +46,7 @@ export async function toMatchAriaSnapshot(if (!testInfo)throw new Error(`toMatchAriaSnapshot() must be called during the test`);- if (testInfo._projectInternal.ignoreSnapshots)+ if (testInfo._projectInternal.project.ignoreSnapshots)return { pass: !this.isNot, message: () => '', name: 'toMatchAriaSnapshot', expected: '' };const updateSnapshots = testInfo.config.updateSnapshots;diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.tsindex 661bf88d07..f2858657f1 100644--- a/packages/playwright/src/matchers/toMatchSnapshot.ts+++ b/packages/playwright/src/matchers/toMatchSnapshot.ts@@ -260,7 +260,7 @@ export function toMatchSnapshot(if (received instanceof Promise)throw new Error('An unresolved Promise was passed to toMatchSnapshot(), make sure to resolve it by adding await to it.');- if (testInfo._projectInternal.ignoreSnapshots)+ if (testInfo._projectInternal.project.ignoreSnapshots)return { pass: !this.isNot, message: () => '', name: 'toMatchSnapshot', expected: nameOrOptions };const configOptions = testInfo._projectInternal.expect?.toMatchSnapshot || {};@@ -329,7 +329,7 @@ export async function toHaveScreenshot(if (!testInfo)throw new Error(`toHaveScreenshot() must be called during the test`);- if (testInfo._projectInternal.ignoreSnapshots)+ if (testInfo._projectInternal.project.ignoreSnapshots)return { pass: !this.isNot, message: () => '', name: 'toHaveScreenshot', expected: nameOrOptions };expectTypes(pageOrLocator, ['Page', 'Locator'], 'toHaveScreenshot');diff --git a/packages/playwright/src/reporters/teleEmitter.ts b/packages/playwright/src/reporters/teleEmitter.tsindex dd09b91ac9..f4066ccfcf 100644--- a/packages/playwright/src/reporters/teleEmitter.ts+++ b/packages/playwright/src/reporters/teleEmitter.ts@@ -215,6 +215,7 @@ export class TeleReporterEmitter implements ReporterV2 {dependencies: project.dependencies,snapshotDir: this._relativePath(project.snapshotDir),teardown: project.teardown,+ ignoreSnapshots: project.ignoreSnapshots ? true : undefined,use: this._serializeProjectUseOptions(project.use),};return report;diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.tsindex 33409b8445..9ed18fdf0e 100644--- a/packages/playwright/types/test.d.ts+++ b/packages/playwright/types/test.d.ts@@ -764,6 +764,11 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {*/grepInvert: null|RegExp|Array<RegExp>;+ /**+ * See [testProject.ignoreSnapshots](https://playwright.dev/docs/api/class-testproject#test-project-ignore-snapshots).+ */+ ignoreSnapshots: boolean;+/*** See [testProject.metadata](https://playwright.dev/docs/api/class-testproject#test-project-metadata).*/