Skip to content

Commit 08d6004

Browse files
committed
test: preserve filename filters in the native iteration shortcut
1 parent aab5187 commit 08d6004

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { join } from 'node:path';
2+
import { loadConfigFromFile } from 'vite-plus';
3+
import { expect, it } from 'vite-plus/test';
4+
import { parseCLI } from 'vite-plus/test/node';
5+
6+
it('keeps a forwarded filename as a filter for the native iteration command', async () => {
7+
const loaded = await loadConfigFromFile(
8+
{ command: 'serve', mode: 'test' },
9+
join(import.meta.dirname, '../../../../vite.config.ts'),
10+
);
11+
const task = loaded?.config.run?.tasks?.['test:iterate'];
12+
if (
13+
!task ||
14+
typeof task !== 'object' ||
15+
!('command' in task) ||
16+
typeof task.command !== 'string'
17+
) {
18+
throw new Error('Expected a native Vitest command');
19+
}
20+
const file = 'packages/void/test/unit/plugin-routing.test.ts';
21+
const { filter, options } = parseCLI(
22+
`${task.command.replace(/^vp test/, 'vitest')} ${file} --project unit`,
23+
);
24+
expect(filter).toEqual([file]);
25+
expect(options.sinceLastRun).toBeTruthy();
26+
expect(options.project).toEqual(['unit']);
27+
});

‎vite.config.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export default defineConfig({
110110
],
111111
},
112112
test: { command: 'node test/affected.mjs', cache: false },
113-
'test:iterate': { command: 'vp test run --since-last-run', cache: false },
113+
'test:iterate': { command: 'vp test run --since-last-run=true', cache: false },
114114
'test:benchmark': {
115115
command: 'vp test run --reporter=default --reporter=./test/performance-reporter.ts',
116116
cache: false,

0 commit comments

Comments
 (0)