Skip to content

Commit

Permalink
chore: allow repetative application of rebaselines in the same session (
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Jan 28, 2025
1 parent 7fd0c3e commit 7060cd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/playwright/src/runner/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export function addSuggestedRebaseline(location: Location, suggestedRebaseline:
suggestedRebaselines.set(location.file, { location, code: suggestedRebaseline });
}

export function clearSuggestedRebaselines() {
suggestedRebaselines.clear();
}

export async function applySuggestedRebaselines(config: FullConfigInternal, reporter: InternalReporter) {
if (config.config.updateSnapshots === 'none')
return;
Expand Down
5 changes: 4 additions & 1 deletion packages/playwright/src/runner/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { detectChangedTestFiles } from './vcs';
import type { InternalReporter } from '../reporters/internalReporter';
import { cacheDir } from '../transform/compilationCache';
import type { FullResult } from '../../types/testReporter';
import { applySuggestedRebaselines } from './rebase';
import { applySuggestedRebaselines, clearSuggestedRebaselines } from './rebase';

const readDirAsync = promisify(fs.readdir);

Expand Down Expand Up @@ -284,6 +284,9 @@ export function createLoadTask(mode: 'out-of-process' | 'in-process', options: {
export function createApplyRebaselinesTask(): Task<TestRun> {
return {
title: 'apply rebaselines',
setup: async () => {
clearSuggestedRebaselines();
},
teardown: async ({ config, reporter }) => {
await applySuggestedRebaselines(config, reporter);
},
Expand Down

0 comments on commit 7060cd1

Please sign in to comment.