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
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 6 additions & 3 deletions packages/vitest/src/node/reporters/base.ts
Expand Up @@ -4,7 +4,7 @@ import type { ErrorWithDiff, File, Reporter, Task, TaskResultPack, UserConsoleLo
import { clearInterval, getFullName, getSuites, getTests, hasFailed, hasFailedSnapshot, isNode, relativePath, setInterval } from '../../utils'
import type { Vitest } from '../../node'
import { F_RIGHT } from '../../utils/figures'
import { divider, getStateString, getStateSymbol, pointer, renderSnapshotSummary } from './renderers/utils'
import { divider, formatTimeString, getStateString, getStateSymbol, pointer, renderSnapshotSummary } from './renderers/utils'

const BADGE_PADDING = ' '
const HELP_HINT = `${c.dim('press ')}${c.bold('h')}${c.dim(' to show help')}`
Expand All @@ -28,6 +28,7 @@ export abstract class BaseReporter implements Reporter {
private _lastRunTimeout = 0
private _lastRunTimer: NodeJS.Timer | undefined
private _lastRunCount = 0
private _timeStart = new Date()

constructor() {
this.registerUnhandledRejection()
Expand Down Expand Up @@ -158,6 +159,7 @@ export abstract class BaseReporter implements Reporter {
this.ctx.logger.clearScreen(`\n${BADGE}${TRIGGER} ${c.blue(`x${rerun}`)}\n`)
}

this._timeStart = new Date()
this.start = performance.now()
}

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

logger.log(padTitle('Test Files'), getStateString(files))
logger.log(padTitle('Tests'), getStateString(tests))
logger.log(padTitle('Start at'), formatTimeString(this._timeStart))
if (this.watchFilters)
logger.log(padTitle('Time'), time(threadTime))
logger.log(padTitle('Duration'), time(threadTime))
else
logger.log(padTitle('Time'), time(executionTime) + c.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`))
logger.log(padTitle('Duration'), time(executionTime) + c.gray(` (setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`))

logger.log()
}
Expand Down
4 changes: 4 additions & 0 deletions packages/vitest/src/node/reporters/renderers/utils.ts
Expand Up @@ -170,3 +170,7 @@ export function elegantSpinner() {
return spinnerFrames[index]
}
}

export function formatTimeString(date: Date) {
return date.toTimeString().split(' ')[0]
}