Skip to content

Commit 931200a

Browse files
authored
fix(vite-plugin-angular): treat the vitest run command as a single run instead of watch mode (#2374)
1 parent cb85e46 commit 931200a

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/vite-plugin-angular/src/lib/angular-vite-plugin.spec.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,24 @@ describe('isTestWatchMode', () => {
3838
expect(result).toBeFalsy();
3939
});
4040

41+
it('should return false for vitest run', () => {
42+
const result = isTestWatchMode(['run']);
43+
44+
expect(result).toBeFalsy();
45+
});
46+
47+
it('should return false for vitest run with a file filter', () => {
48+
const result = isTestWatchMode(['run', 'src/example.spec.ts']);
49+
50+
expect(result).toBeFalsy();
51+
});
52+
53+
it('should return true for a file filter that contains run', () => {
54+
const result = isTestWatchMode(['src/run-helpers.spec.ts']);
55+
56+
expect(result).toBeTruthy();
57+
});
58+
4159
it('should return true for vitest --no-run', () => {
4260
const result = isTestWatchMode(['--no-run']);
4361

‎packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,11 @@ export function isTestWatchMode(args = process.argv) {
18251825
return false;
18261826
}
18271827

1828+
// vitest run
1829+
if (args.includes('run')) {
1830+
return false;
1831+
}
1832+
18281833
// vitest --no-run
18291834
const hasNoRun = args.find((arg) => arg.includes('--no-run'));
18301835
if (hasNoRun) {

0 commit comments

Comments
 (0)