cherry-pick(#34524): chore: allow repetative application of rebaselines in the same session
This commit is contained in:
parent
0213cf57bd
commit
50a58f992b
|
|
@ -43,6 +43,10 @@ export function addSuggestedRebaseline(location: Location, suggestedRebaseline:
|
||||||
suggestedRebaselines.set(location.file, { location, code: suggestedRebaseline });
|
suggestedRebaselines.set(location.file, { location, code: suggestedRebaseline });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearSuggestedRebaselines() {
|
||||||
|
suggestedRebaselines.clear();
|
||||||
|
}
|
||||||
|
|
||||||
export async function applySuggestedRebaselines(config: FullConfigInternal, reporter: InternalReporter) {
|
export async function applySuggestedRebaselines(config: FullConfigInternal, reporter: InternalReporter) {
|
||||||
if (config.config.updateSnapshots === 'none')
|
if (config.config.updateSnapshots === 'none')
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import { detectChangedTestFiles } from './vcs';
|
||||||
import type { InternalReporter } from '../reporters/internalReporter';
|
import type { InternalReporter } from '../reporters/internalReporter';
|
||||||
import { cacheDir } from '../transform/compilationCache';
|
import { cacheDir } from '../transform/compilationCache';
|
||||||
import type { FullResult } from '../../types/testReporter';
|
import type { FullResult } from '../../types/testReporter';
|
||||||
import { applySuggestedRebaselines } from './rebase';
|
import { applySuggestedRebaselines, clearSuggestedRebaselines } from './rebase';
|
||||||
|
|
||||||
const readDirAsync = promisify(fs.readdir);
|
const readDirAsync = promisify(fs.readdir);
|
||||||
|
|
||||||
|
|
@ -284,6 +284,9 @@ export function createLoadTask(mode: 'out-of-process' | 'in-process', options: {
|
||||||
export function createApplyRebaselinesTask(): Task<TestRun> {
|
export function createApplyRebaselinesTask(): Task<TestRun> {
|
||||||
return {
|
return {
|
||||||
title: 'apply rebaselines',
|
title: 'apply rebaselines',
|
||||||
|
setup: async () => {
|
||||||
|
clearSuggestedRebaselines();
|
||||||
|
},
|
||||||
teardown: async ({ config, reporter }) => {
|
teardown: async ({ config, reporter }) => {
|
||||||
await applySuggestedRebaselines(config, reporter);
|
await applySuggestedRebaselines(config, reporter);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue