Skip to content

Commit

Permalink
[minor] support snapshots in web tests
Browse files Browse the repository at this point in the history
  • Loading branch information
electrovir committed Nov 7, 2024
1 parent 374eb50 commit dbb595a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/test/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ export const virmatorTestPlugin = defineVirmatorPlugin(
],
},
},
update: {
doc: {
sections: [
`
Run tests and update snapshots.
`,
],
examples: [
{
content: 'virmator test web update',
},
],
},
},
},
configFiles: {
webTestRunner: {
Expand Down Expand Up @@ -282,6 +296,7 @@ export const virmatorTestPlugin = defineVirmatorPlugin(

if (usedCommands.test?.subCommands.web) {
const allFilesTestFilePath = join(cwd, 'src', 'all-files-for-code-coverage.test.ts');
const shouldUpdateSnapshots = usedCommands.test.subCommands.web.subCommands.update;

try {
const configPath =
Expand All @@ -301,6 +316,7 @@ export const virmatorTestPlugin = defineVirmatorPlugin(
.default as Partial<TestRunnerConfig>;

const includeCoverage = usedCommands.test.subCommands.web.subCommands.coverage;
const updateSnapshotsArgs = shouldUpdateSnapshots ? ['--update-snapshots'] : [];

if (includeCoverage) {
await createTestThatImportsAllFilesForCoverage(
Expand All @@ -315,6 +331,7 @@ export const virmatorTestPlugin = defineVirmatorPlugin(
'web-test-runner',
'--color',
...configArgs,
...updateSnapshotsArgs,
includeCoverage ? '--coverage' : '',
...filteredArgs,
]
Expand Down

0 comments on commit dbb595a

Please sign in to comment.