From 73d653dc2dd82c005adf3ec8b358a909ab748804 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 13 Sep 2022 20:05:16 -0400 Subject: [PATCH 1/3] fix(ignoreSnapshots): print a notice when ignoreSnapshots option is on --- packages/playwright-test/src/runner.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index 6cd71b5016fdf..0d48469ef99c4 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -29,6 +29,7 @@ import { Loader } from './loader'; import type { FullResult, Reporter, TestError } from '../types/testReporter'; import { Multiplexer } from './reporters/multiplexer'; import { formatError } from './reporters/base'; +import { colors } from 'playwright-core/lib/utilsBundle'; import DotReporter from './reporters/dot'; import GitHubReporter from './reporters/github'; import LineReporter from './reporters/line'; @@ -603,6 +604,15 @@ export class Runner { } }; + if (config._ignoreSnapshots) { + this._reporter.onStdOut?.(colors.dim([ + 'NOTE: running with "ignoreSnapshots" option. All of the following asserts are silently ignored:', + '- expect().toMatchSnapshot()', + '- expect().toHaveScreenshot()', + '', + ].join('\n'))); + } + // Legacy webServer support. this._plugins.push(...webServerPluginsForConfig(config)); From 828a0a230d03671b192e95c13ee99e778695d78f Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 14 Sep 2022 11:16:05 -0400 Subject: [PATCH 2/3] address comments --- packages/playwright-test/src/runner.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index 0d48469ef99c4..355629bed749d 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -402,6 +402,15 @@ export class Runner { if (result.status !== 'passed') return result; + if (config._ignoreSnapshots) { + reporter.onStdOut?.(colors.yellow([ + 'NOTE: running with "ignoreSnapshots" option. All of the following asserts are silently ignored:', + '- expect().toMatchSnapshot()', + '- expect().toHaveScreenshot()', + '', + ].join('\n'))); + } + // 14. Run tests. try { const sigintWatcher = new SigIntWatcher(); @@ -604,15 +613,6 @@ export class Runner { } }; - if (config._ignoreSnapshots) { - this._reporter.onStdOut?.(colors.dim([ - 'NOTE: running with "ignoreSnapshots" option. All of the following asserts are silently ignored:', - '- expect().toMatchSnapshot()', - '- expect().toHaveScreenshot()', - '', - ].join('\n'))); - } - // Legacy webServer support. this._plugins.push(...webServerPluginsForConfig(config)); From 26759a8f70f0f366556cfc55370f4ec157844e81 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 14 Sep 2022 11:22:18 -0400 Subject: [PATCH 3/3] fix colors --- packages/playwright-test/src/runner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index 355629bed749d..144c188cb7b7c 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -403,7 +403,7 @@ export class Runner { return result; if (config._ignoreSnapshots) { - reporter.onStdOut?.(colors.yellow([ + this._reporter.onStdOut?.(colors.dim([ 'NOTE: running with "ignoreSnapshots" option. All of the following asserts are silently ignored:', '- expect().toMatchSnapshot()', '- expect().toHaveScreenshot()',