-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ssr): disable snapshot updates in fixtures (#4968)
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { VitestTestRunner } from 'vitest/runners'; | ||
import type { RunnerTask } from 'vitest'; | ||
|
||
export default class SsrTestRunner extends VitestTestRunner { | ||
override onAfterRunTask(task: RunnerTask): void { | ||
// In the test file `src/__tests__/fixtures.spec.ts` we are matching snapshots from engine-server | ||
// We want to avoid updating snapshots here, so we replace 'Snapshot' with 'SSR Fixture' in error messages | ||
// This is a workaround while vitest does not provide a way to skip updating snapshots for specific tests | ||
// https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/utils/tasks.ts#L12-L20 | ||
// This shouldn't be a problem in CI, as updating snapshots is globally disabled | ||
if (task.file.name === 'src/__tests__/fixtures.spec.ts') { | ||
task.result?.errors?.forEach((error) => { | ||
error.message = error.message.replaceAll('Snapshot', 'SSR Fixture'); | ||
}); | ||
} | ||
|
||
return super.onAfterRunTask(task); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters