Skip to content

Commit

Permalink
fix(ignoreSnapshots): print a notice when ignoreSnapshots option is on
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Sep 14, 2022
1 parent dfcd2a2 commit b26de76
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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')));
}
},
};
4 changes: 4 additions & 0 deletions packages/playwright-test/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -603,6 +604,9 @@ export class Runner {
}
};

// The ignoreSnapshots notice
this._plugins.push(ignoreSnapshotsPlugin);

// Legacy webServer support.
this._plugins.push(...webServerPluginsForConfig(config));

Expand Down

0 comments on commit b26de76

Please sign in to comment.