Skip to content

Commit

Permalink
chore: check duration is set
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 15, 2024
1 parent 42ccebd commit e84033c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/vitest/src/node/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export abstract class BaseReporter implements Reporter {
logger.log(title)

for (const test of tests) {
const duration = test.result?.duration || 0
const duration = test.result?.duration
if (test.result?.state === 'fail') {
logger.log(c.red(` ${taskFail} ${getTestName(test, c.dim(' > '))}`))
const suffix = this.getDurationPrefix(test)
Expand All @@ -160,7 +160,7 @@ export abstract class BaseReporter implements Reporter {
})
}
// also print slow tests
else if (duration > this.ctx.config.slowTestThreshold) {
else if (duration && duration > this.ctx.config.slowTestThreshold) {
logger.log(
` ${c.yellow(c.dim(F_CHECK))} ${getTestName(test, c.dim(' > '))}${c.yellow(
` ${Math.round(duration)}${c.dim('ms')}`,
Expand All @@ -174,10 +174,9 @@ export abstract class BaseReporter implements Reporter {
if (!task.result?.duration) {
return ''
}
const color
= task.result.duration > this.ctx.config.slowTestThreshold
? c.yellow
: c.gray
const color = task.result.duration > this.ctx.config.slowTestThreshold
? c.yellow
: c.gray
return color(` ${Math.round(task.result.duration)}${c.dim('ms')}`)
}

Expand Down

0 comments on commit e84033c

Please sign in to comment.