Skip to content

Commit ba6da4d

Browse files
authored
fix(typecheck): don't panic during vitest list command (#7933)
1 parent 525f524 commit ba6da4d

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

packages/vitest/src/node/pools/typecheck.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ export function createTypecheckPool(ctx: Vitest): ProcessPool {
118118
checker.setFiles(files)
119119
await checker.collectTests()
120120
const testFiles = checker.getTestFiles()
121-
for (const file of testFiles) {
122-
await ctx._testRun.enqueued(project, file)
123-
}
124-
await ctx._testRun.collected(project, testFiles)
121+
ctx.state.collectFiles(project, testFiles)
125122
}
126123
}
127124

test/cli/fixtures/list/type.test-d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expectTypeOf, it } from 'vitest'
2+
3+
it('1 plus 1', () => {
4+
expectTypeOf(1 + 1).toBeNumber()
5+
})

test/cli/test/__snapshots__/list.test.ts.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,22 @@ math.test.ts > failing test
5959
"
6060
`;
6161
62+
exports[`correctly outputs all tests with args: "--typecheck" 1`] = `
63+
"type.test-d.ts > 1 plus 1
64+
basic.test.ts > basic suite > inner suite > some test
65+
basic.test.ts > basic suite > inner suite > another test
66+
basic.test.ts > basic suite > basic test
67+
basic.test.ts > outside test
68+
math.test.ts > 1 plus 1
69+
math.test.ts > failing test
70+
"
71+
`;
72+
73+
exports[`correctly outputs all tests with args: "--typecheck.only" 1`] = `
74+
"type.test-d.ts > 1 plus 1
75+
"
76+
`;
77+
6278
exports[`json output shows error 1`] = `
6379
"Error: describe error
6480
❯ describe-error.test.ts:4:9

test/cli/test/list.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ test.each([
77
['--pool=forks'],
88
['--pool=vmForks'],
99
['--browser.enabled'],
10+
['--typecheck'],
11+
['--typecheck.only'],
1012
])('correctly outputs all tests with args: "%s"', async (...args) => {
1113
const { stdout, exitCode } = await runVitestCli('list', '-r=./fixtures/list', ...args)
1214
expect(stdout).toMatchSnapshot()

0 commit comments

Comments
 (0)