Skip to content

Commit 66fbed3

Browse files
committed
fix(typecheck): correctly run both runtime and typecheck tests if typecheck.include overlaps with include
1 parent af2b813 commit 66fbed3

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

packages/vitest/src/node/pool.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,7 @@ export const builtinPools: BuiltinPool[] = [
3939
'typescript',
4040
]
4141

42-
function getDefaultPoolName(project: WorkspaceProject, file: string): Pool {
43-
if (project.config.typecheck.enabled) {
44-
for (const glob of project.config.typecheck.include) {
45-
if (mm.isMatch(file, glob, { cwd: project.config.root })) {
46-
return 'typescript'
47-
}
48-
}
49-
}
42+
function getDefaultPoolName(project: WorkspaceProject): Pool {
5043
if (project.config.browser.enabled) {
5144
return 'browser'
5245
}
@@ -64,7 +57,7 @@ export function getFilePoolName(project: WorkspaceProject, file: string) {
6457
return pool as Pool
6558
}
6659
}
67-
return getDefaultPoolName(project, file)
60+
return getDefaultPoolName(project)
6861
}
6962

7063
export function createPool(ctx: Vitest): ProcessPool {
@@ -174,9 +167,19 @@ export function createPool(ctx: Vitest): ProcessPool {
174167
}
175168

176169
for (const spec of files) {
177-
const pool = getFilePoolName(spec[0], spec[1])
170+
const [project, file] = spec
171+
const pool = getFilePoolName(project, file)
178172
filesByPool[pool] ??= []
179173
filesByPool[pool].push(spec)
174+
175+
if (project.config.typecheck.enabled) {
176+
for (const glob of project.config.typecheck.include) {
177+
if (mm.isMatch(file, glob, { cwd: project.config.root })) {
178+
filesByPool.typescript ??= []
179+
filesByPool.typescript.push(spec)
180+
}
181+
}
182+
}
180183
}
181184

182185
const Sequencer = ctx.config.sequence.sequencer

packages/vitest/src/typecheck/collect.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,18 @@ export async function collectTests(
5454
}
5555
const ast = await parseAstAsync(request.code)
5656
const testFilepath = relative(ctx.config.root, filepath)
57+
const projectName = ctx.getName()
58+
const typecheckSubprojectName = projectName ? `${projectName}:typecheck` : 'typecheck'
5759
const file: ParsedFile = {
5860
filepath,
5961
type: 'suite',
60-
id: generateHash(`${testFilepath}${ctx.config.name || ''}`),
62+
id: generateHash(`${testFilepath}${typecheckSubprojectName}`),
6163
name: testFilepath,
6264
mode: 'run',
6365
tasks: [],
6466
start: ast.start,
6567
end: ast.end,
66-
projectName: ctx.getName(),
68+
projectName,
6769
meta: { typecheck: true },
6870
file: null!,
6971
}

0 commit comments

Comments
 (0)