Skip to content

Commit 1769c79

Browse files
authoredJan 5, 2024
fix(vitest): apply slowTestThreshold to all reporters (#4876)
1 parent 7719e79 commit 1769c79

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed
 

‎packages/vitest/src/node/reporters/benchmark/table/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class TableReporter extends BaseReporter {
2222
if (this.isTTY) {
2323
this.rendererOptions.logger = this.ctx.logger
2424
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage
25+
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold
2526
const files = this.ctx.state.getFiles(this.watchFilters)
2627
if (!this.renderer)
2728
this.renderer = createTableRenderer(files, this.rendererOptions).start()

‎packages/vitest/src/node/reporters/benchmark/table/tableRender.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ export interface ListRendererOptions {
1111
renderSucceed?: boolean
1212
logger: Logger
1313
showHeap: boolean
14+
slowTestThreshold: number
1415
}
1516

16-
const DURATION_LONG = 300
17-
1817
const outputMap = new WeakMap<Task, string>()
1918

2019
function formatFilepath(path: string) {
@@ -121,7 +120,7 @@ export function renderTree(tasks: Task[], options: ListRendererOptions, level =
121120
suffix += ` ${c.dim(c.gray('[skipped]'))}`
122121

123122
if (task.result?.duration != null) {
124-
if (task.result.duration > DURATION_LONG)
123+
if (task.result.duration > options.slowTestThreshold)
125124
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim('ms')}`)
126125
}
127126

‎packages/vitest/src/node/reporters/default.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class DefaultReporter extends BaseReporter {
3333
if (this.isTTY) {
3434
this.rendererOptions.logger = this.ctx.logger
3535
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage
36+
this.rendererOptions.slowTestThreshold = this.ctx.config.slowTestThreshold
3637
this.rendererOptions.mode = this.mode
3738
const files = this.ctx.state.getFiles(this.watchFilters)
3839
if (!this.renderer)

‎packages/vitest/src/node/reporters/renderers/listRenderer.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ export interface ListRendererOptions {
1111
renderSucceed?: boolean
1212
logger: Logger
1313
showHeap: boolean
14+
slowTestThreshold: number
1415
mode: VitestRunMode
1516
}
1617

17-
const DURATION_LONG = 300
18-
1918
const outputMap = new WeakMap<Task, string>()
2019

2120
function formatFilepath(path: string) {
@@ -115,7 +114,7 @@ export function renderTree(tasks: Task[], options: ListRendererOptions, level =
115114
suffix += c.yellow(` (repeat x${task.result.repeatCount})`)
116115

117116
if (task.result?.duration != null) {
118-
if (task.result.duration > DURATION_LONG)
117+
if (task.result.duration > options.slowTestThreshold)
119118
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim('ms')}`)
120119
}
121120

0 commit comments

Comments
 (0)
Please sign in to comment.