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

feat: show start time in test summary #1734

Merged
merged 4 commits into from Aug 2, 2022
Merged
Changes from 1 commit
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
24 changes: 15 additions & 9 deletions packages/vitest/src/node/reporters/base.ts
Expand Up @@ -7,9 +7,9 @@ import { F_RIGHT } from '../../utils/figures'
import { divider, getStateString, getStateSymbol, pointer, renderSnapshotSummary } from './renderers/utils'

const BADGE_PADDING = ' '
const HELP_HINT = `${c.dim('press ')}${c.bold('h')}${c.dim(' to show help')}`
const HELP_UPDATE_SNAP = c.dim('press ') + c.bold(c.yellow('u')) + c.dim(' to update snapshot')
const HELP_QUITE = `${c.dim('press ')}${c.bold('q')}${c.dim(' to quit')}`
const HELP_HINT = `${c.dim('Press ')}${c.bold('h')}${c.dim(' to show help')}`
const HELP_UPDATE_SNAP = c.dim('Press ') + c.bold(c.yellow('u')) + c.dim(' to update snapshot')
const HELP_QUITE = `${c.dim('Press ')}${c.bold('q')}${c.dim(' to quit')}`

const WAIT_FOR_CHANGE_PASS = `\n${c.bold(c.inverse(c.green(' PASS ')))}${c.green(' Waiting for file changes...')}`
const WAIT_FOR_CHANGE_FAIL = `\n${c.bold(c.inverse(c.red(' FAIL ')))}${c.red(' Tests failed. Watching for file changes...')}`
Expand All @@ -28,6 +28,7 @@ export abstract class BaseReporter implements Reporter {
private _lastRunTimeout = 0
private _lastRunTimer: NodeJS.Timer | undefined
private _lastRunCount = 0
private _timeNow = ''

constructor() {
this.registerUnhandledRejection()
Expand All @@ -37,6 +38,7 @@ export abstract class BaseReporter implements Reporter {
this.ctx = ctx

ctx.logger.printBanner()
this._timeNow = new Date().toTimeString().split(' ')[0]
this.start = performance.now()
}

Expand Down Expand Up @@ -109,11 +111,13 @@ export abstract class BaseReporter implements Reporter {
this.ctx.logger.log(BADGE_PADDING + hints.join(c.dim(', ')))

if (this._lastRunCount) {
const LAST_RUN_TEXT = `rerun x${this._lastRunCount}`
const LAST_RUN_TEXT = `Running Test(s) x${this._lastRunCount}`
const LAST_RUN_TEXTS = [
c.blue(LAST_RUN_TEXT),
c.gray(LAST_RUN_TEXT),
c.dim(c.gray(LAST_RUN_TEXT)),
c.bold(c.blue(`${LAST_RUN_TEXT} .`)),
c.blue(`${LAST_RUN_TEXT} ..`),
c.bold(c.gray(`${LAST_RUN_TEXT} ...`)),
c.gray(`${LAST_RUN_TEXT} ....`),
c.dim(c.gray(`${LAST_RUN_TEXT} .....`)),
]
this.ctx.logger.logUpdate(BADGE_PADDING + LAST_RUN_TEXTS[0])
this._lastRunTimeout = 0
Expand Down Expand Up @@ -158,6 +162,7 @@ export abstract class BaseReporter implements Reporter {
this.ctx.logger.clearScreen(`\n${BADGE}${TRIGGER} ${c.blue(`x${rerun}`)}\n`)
}

this._timeNow = new Date().toTimeString().split(' ')[0]
this.start = performance.now()
}

Expand Down Expand Up @@ -230,11 +235,12 @@ export abstract class BaseReporter implements Reporter {

logger.log(padTitle('Test Files'), getStateString(files))
logger.log(padTitle('Tests'), getStateString(tests))
logger.log(padTitle('Start Time'), this._timeNow)
if (this.watchFilters)
logger.log(padTitle('Time'), time(threadTime))
logger.log(padTitle('Duration'), time(threadTime))

else
logger.log(padTitle('Time'), time(executionTime) + c.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`))
logger.log(padTitle('Duration'), time(executionTime) + c.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`))

logger.log()
}
Expand Down