Skip to content

Commit

Permalink
fix: verbose benchmark reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Dec 11, 2024
1 parent 412c67a commit 3dc0b49
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/vitest/src/node/reporters/benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { VerboseReporter } from '../verbose'
import { BenchmarkReporter } from './reporter'
import { VerboseBenchmarkReporter } from './verbose'

export const BenchmarkReportsMap = {
default: BenchmarkReporter,
verbose: VerboseReporter,
verbose: VerboseBenchmarkReporter,
}

export type BenchmarkBuiltinReporters = keyof typeof BenchmarkReportsMap
3 changes: 1 addition & 2 deletions packages/vitest/src/node/reporters/benchmark/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { createBenchmarkJsonReport, flattenFormattedBenchmarkReport } from './js
import { renderTable } from './tableRender'

export class BenchmarkReporter extends DefaultReporter {
protected verbose = true
compare?: Parameters<typeof renderTable>[0]['compare']

async onInit(ctx: Vitest) {
Expand Down Expand Up @@ -41,7 +40,7 @@ export class BenchmarkReporter extends DefaultReporter {
const duration = task.result.duration

if (benches.length > 0 && benches.every(t => t.result?.state !== 'run')) {
let title = ` ${getStateSymbol(task)} ${getFullName(task, c.dim(' > '))}`
let title = `\n ${getStateSymbol(task)} ${getFullName(task, c.dim(' > '))}`

if (duration != null && duration > this.ctx.config.slowTestThreshold) {
title += c.yellow(` ${Math.round(duration)}${c.dim('ms')}`)
Expand Down
5 changes: 5 additions & 0 deletions packages/vitest/src/node/reporters/benchmark/verbose.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BenchmarkReporter } from './reporter'

export class VerboseBenchmarkReporter extends BenchmarkReporter {
protected verbose = true
}
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3dc0b49

Please sign in to comment.