diff --git a/packages/playwright-test/src/plugins/ignoreSnapshotsNoticePlugin.ts b/packages/playwright-test/src/plugins/ignoreSnapshotsNoticePlugin.ts new file mode 100644 index 00000000000000..c1456ac1e0f23d --- /dev/null +++ b/packages/playwright-test/src/plugins/ignoreSnapshotsNoticePlugin.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import type { Reporter, Suite } from '../../types/testReporter'; +import type { FullConfigInternal } from '../types'; +import { colors } from 'playwright-core/lib/utilsBundle'; + +export const ignoreSnapshotsPlugin = { + name: 'playwright:ignore-snapshots-notice', + + async setup(config: FullConfigInternal, configDir: string, rootSuite: Suite, reporter: Reporter) { + 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'))); + } + }, +}; diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index 6cd71b5016fdf6..976faf42aaa450 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -44,6 +44,7 @@ import { SigIntWatcher } from './sigIntWatcher'; import type { TestRunnerPlugin } from './plugins'; import { setRunnerToAddPluginsTo } from './plugins'; import { webServerPluginsForConfig } from './plugins/webServerPlugin'; +import { ignoreSnapshotsPlugin } from './plugins/ignoreSnapshotsNoticePlugin'; import { dockerPlugin } from './docker/docker'; import { MultiMap } from 'playwright-core/lib/utils/multimap'; @@ -603,6 +604,9 @@ export class Runner { } }; + // The ignoreSnapshots notice + this._plugins.push(ignoreSnapshotsPlugin); + // Legacy webServer support. this._plugins.push(...webServerPluginsForConfig(config));