Skip to content

Commit 32a577b

Browse files
authoredDec 31, 2022
fix: show list of tests when typechecking (#2585)
1 parent c479d9c commit 32a577b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
 

‎packages/vitest/src/node/core.ts

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ export class Vitest {
160160
this.typechecker = checker
161161
checker.onParseEnd(async ({ files, sourceErrors }) => {
162162
this.state.collectFiles(checker.getTestFiles())
163+
await this.report('onTaskUpdate', checker.getTestPacks())
163164
await this.report('onCollected')
164165
if (!files.length) {
165166
this.logger.printNoTestFound()
@@ -194,6 +195,7 @@ export class Vitest {
194195
await this.report('onWatcherRerun', testsFilesList, 'File change detected. Triggering rerun.')
195196
await checker.collectTests()
196197
this.state.collectFiles(checker.getTestFiles())
198+
await this.report('onTaskUpdate', checker.getTestPacks())
197199
await this.report('onCollected')
198200
})
199201
await checker.collectTests()

‎packages/vitest/src/typecheck/collect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export async function collectTests(ctx: Vitest, filepath: string): Promise<null
4545
const file: ParsedFile = {
4646
filepath,
4747
type: 'suite',
48-
id: '-1',
48+
id: filepath,
4949
name: relative(ctx.config.root, filepath),
5050
mode: 'run',
5151
tasks: [],

‎packages/vitest/src/typecheck/typechecker.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { execa } from 'execa'
44
import { resolve } from 'pathe'
55
import { SourceMapConsumer } from 'source-map'
66
import { ensurePackageInstalled } from '../utils'
7-
import type { Awaitable, File, ParsedStack, Task, TaskState, TscErrorInfo, Vitest } from '../types'
7+
import type { Awaitable, File, ParsedStack, Task, TaskResultPack, TaskState, TscErrorInfo, Vitest } from '../types'
88
import { getRawErrsMapFromTsCompile, getTsconfigPath } from './parse'
99
import { createIndexMap } from './utils'
1010
import type { FileInformation } from './collect'
@@ -108,7 +108,7 @@ export class Typechecker {
108108
const state: TaskState = suite.mode === 'run' || suite.mode === 'only' ? 'fail' : suite.mode
109109
const task: Task = {
110110
type: 'typecheck',
111-
id: idx.toString(),
111+
id: `${path}${idx.toString()}`,
112112
name: `error expect ${idx + 1}`, // TODO naming
113113
mode: suite.mode,
114114
file,
@@ -234,4 +234,8 @@ export class Typechecker {
234234
public getTestFiles() {
235235
return Object.values(this._tests || {}).map(i => i.file)
236236
}
237+
238+
public getTestPacks() {
239+
return Object.values(this._tests || {}).map(i => [i.file.id, undefined] as TaskResultPack)
240+
}
237241
}

0 commit comments

Comments
 (0)
Please sign in to comment.