Skip to content

Commit

Permalink
fix: show list of tests when typechecking (#2585)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 31, 2022
1 parent c479d9c commit 32a577b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/vitest/src/node/core.ts
Expand Up @@ -160,6 +160,7 @@ export class Vitest {
this.typechecker = checker
checker.onParseEnd(async ({ files, sourceErrors }) => {
this.state.collectFiles(checker.getTestFiles())
await this.report('onTaskUpdate', checker.getTestPacks())
await this.report('onCollected')
if (!files.length) {
this.logger.printNoTestFound()
Expand Down Expand Up @@ -194,6 +195,7 @@ export class Vitest {
await this.report('onWatcherRerun', testsFilesList, 'File change detected. Triggering rerun.')
await checker.collectTests()
this.state.collectFiles(checker.getTestFiles())
await this.report('onTaskUpdate', checker.getTestPacks())
await this.report('onCollected')
})
await checker.collectTests()
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/typecheck/collect.ts
Expand Up @@ -45,7 +45,7 @@ export async function collectTests(ctx: Vitest, filepath: string): Promise<null
const file: ParsedFile = {
filepath,
type: 'suite',
id: '-1',
id: filepath,
name: relative(ctx.config.root, filepath),
mode: 'run',
tasks: [],
Expand Down
8 changes: 6 additions & 2 deletions packages/vitest/src/typecheck/typechecker.ts
Expand Up @@ -4,7 +4,7 @@ import { execa } from 'execa'
import { resolve } from 'pathe'
import { SourceMapConsumer } from 'source-map'
import { ensurePackageInstalled } from '../utils'
import type { Awaitable, File, ParsedStack, Task, TaskState, TscErrorInfo, Vitest } from '../types'
import type { Awaitable, File, ParsedStack, Task, TaskResultPack, TaskState, TscErrorInfo, Vitest } from '../types'
import { getRawErrsMapFromTsCompile, getTsconfigPath } from './parse'
import { createIndexMap } from './utils'
import type { FileInformation } from './collect'
Expand Down Expand Up @@ -108,7 +108,7 @@ export class Typechecker {
const state: TaskState = suite.mode === 'run' || suite.mode === 'only' ? 'fail' : suite.mode
const task: Task = {
type: 'typecheck',
id: idx.toString(),
id: `${path}${idx.toString()}`,
name: `error expect ${idx + 1}`, // TODO naming
mode: suite.mode,
file,
Expand Down Expand Up @@ -234,4 +234,8 @@ export class Typechecker {
public getTestFiles() {
return Object.values(this._tests || {}).map(i => i.file)
}

public getTestPacks() {
return Object.values(this._tests || {}).map(i => [i.file.id, undefined] as TaskResultPack)
}
}

0 comments on commit 32a577b

Please sign in to comment.