Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default reporter regression #2292

Merged
merged 2 commits into from Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/vitest/src/node/core.ts
Expand Up @@ -158,7 +158,8 @@ export class Vitest {
const checker = new Typechecker(this, testsFilesList)
this.typechecker = checker
checker.onParseEnd(async ({ files, sourceErrors }) => {
await this.report('onCollected', files)
this.state.collectFiles(checker.getTestFiles())
await this.report('onCollected')
if (!files.length)
this.logger.printNoTestFound()
else
Expand All @@ -181,12 +182,14 @@ export class Vitest {
})
checker.onParseStart(async () => {
await this.report('onInit', this)
await this.report('onCollected', checker.getTestFiles())
this.state.collectFiles(checker.getTestFiles())
await this.report('onCollected')
})
checker.onWatcherRerun(async () => {
await this.report('onWatcherRerun', testsFilesList, 'File change detected. Triggering rerun.')
await checker.collectTests()
await this.report('onCollected', checker.getTestFiles())
this.state.collectFiles(checker.getTestFiles())
await this.report('onCollected')
})
await checker.collectTests()
await checker.start()
Expand Down
7 changes: 3 additions & 4 deletions packages/vitest/src/node/reporters/default.ts
@@ -1,5 +1,5 @@
import c from 'picocolors'
import type { File, UserConsoleLog } from '../../types'
import type { UserConsoleLog } from '../../types'
import { BaseReporter } from './base'
import type { ListRendererOptions } from './renderers/listRenderer'
import { createListRenderer } from './renderers/listRenderer'
Expand All @@ -18,13 +18,12 @@ export class DefaultReporter extends BaseReporter {
super.onWatcherStart()
}

onCollected(files?: File[]) {
onCollected() {
if (this.isTTY) {
this.rendererOptions.logger = this.ctx.logger
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage
this.rendererOptions.mode = this.mode
if (!files)
files = this.ctx.state.getFiles(this.watchFilters)
const files = this.ctx.state.getFiles(this.watchFilters)
if (!this.renderer)
this.renderer = createListRenderer(files, this.rendererOptions).start()
else
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/typecheck/collect.ts
Expand Up @@ -27,7 +27,7 @@ interface LocalCallDefinition {
}

export interface FileInformation {
file: ParsedFile
file: File
filepath: string
parsed: string
map: RawSourceMap | null
Expand Down
9 changes: 3 additions & 6 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, TscErrorInfo, Vitest } from '../types'
import type { Awaitable, File, ParsedStack, Task, TaskState, TscErrorInfo, Vitest } from '../types'
import { getRawErrsMapFromTsCompile, getTsconfigPath } from './parse'
import { createIndexMap } from './utils'
import type { FileInformation } from './collect'
Expand Down Expand Up @@ -105,7 +105,7 @@ export class Typechecker {
const index = indexMap.get(`${originalPos.line}:${originalPos.column}`)
const definition = (index != null && sortedDefinitions.find(def => def.start <= index && def.end >= index)) || file
const suite = 'task' in definition ? definition.task : definition
const state = suite.mode === 'run' || suite.mode === 'only' ? 'fail' : suite.mode
const state: TaskState = suite.mode === 'run' || suite.mode === 'only' ? 'fail' : suite.mode
const task: Task = {
type: 'typecheck',
id: idx.toString(),
Expand Down Expand Up @@ -236,9 +236,6 @@ export class Typechecker {
}

public getTestFiles() {
return Object.values(this._tests || {}).map(({ file }) => ({
...file,
result: undefined,
}))
return Object.values(this._tests || {}).map(i => i.file)
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
}
}