Skip to content

Commit

Permalink
fix: dont't print summary if there are no tests to run
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 14, 2025
1 parent 6d92219 commit b1732d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/vitest/src/node/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ export class Logger {
}
this.ctx.projects.forEach((project) => {
const config = project.config
const output = (project.isRootProject() || !project.name) ? '' : `[${project.name}]`
if (output) {
this.console.error(c.bgCyan(`${output} Config`))
const printConfig = !project.isRootProject() && project.name
if (printConfig) {
this.console.error(`\n${formatProjectName(project.name)}Config:\n`)
}
if (config.include) {
this.console.error(
Expand Down
18 changes: 7 additions & 11 deletions packages/vitest/src/node/reporters/default.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { File } from '@vitest/runner'
import type { Vitest } from '../core'
import type { TestSpecification } from '../spec'
import type { BaseOptions } from './base'
import type { ReportedHookContext, TestCase, TestModule } from './reported-tasks'
import { BaseReporter } from './base'
Expand Down Expand Up @@ -29,6 +29,10 @@ export class DefaultReporter extends BaseReporter {
}
}

onTestRunStart(specifications: ReadonlyArray<TestSpecification>) {
this.summary?.onTestRunStart(specifications)
}

onTestModuleQueued(file: TestModule) {
this.summary?.onTestModuleQueued(file)
}
Expand Down Expand Up @@ -72,17 +76,9 @@ export class DefaultReporter extends BaseReporter {
this.renderSucceed = paths.length <= 1
}
}

this.summary?.onPathsCollected(paths)
}

onWatcherRerun(files: string[], trigger?: string) {
this.summary?.onWatcherRerun()
super.onWatcherRerun(files, trigger)
}

onFinished(files?: File[], errors?: unknown[]) {
this.summary?.onFinished()
super.onFinished(files, errors)
onTestRunEnd() {
this.summary?.onTestRunEnd()
}
}
13 changes: 5 additions & 8 deletions packages/vitest/src/node/reporters/summary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Vitest } from '../core'
import type { TestSpecification } from '../spec'
import type { Reporter } from '../types/reporter'
import type { ReportedHookContext, TestCase, TestModule } from './reported-tasks'
import c from 'tinyrainbow'
Expand Down Expand Up @@ -75,29 +76,25 @@ export class SummaryReporter implements Reporter {
getWindow: () => this.createSummary(),
})

this.startTimers()

this.ctx.onClose(() => {
clearInterval(this.durationInterval)
this.renderer.stop()
})
}

onPathsCollected(paths?: string[]) {
this.modules.total = (paths || []).length
}

onWatcherRerun() {
onTestRunStart(specifications: ReadonlyArray<TestSpecification>) {
this.runningModules.clear()
this.finishedModules.clear()
this.modules = emptyCounters()
this.tests = emptyCounters()

this.startTimers()
this.renderer.start()

this.modules.total = specifications.length
}

onFinished() {
onTestRunEnd() {
this.runningModules.clear()
this.finishedModules.clear()
this.renderer.finish()
Expand Down

0 comments on commit b1732d9

Please sign in to comment.