Skip to content

Commit 623d8e6

Browse files
committed
chore(tests): refactor verbose reporter
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 7eb8151 commit 623d8e6

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

__tests__/reporters/verbose.mts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
import type { Task, TaskResultPack } from '@vitest/runner'
88
import { getNames, getTests } from '@vitest/runner/utils'
9-
import { performance } from 'node:perf_hooks'
109
import colors, { type Colors } from 'tinyrainbow'
11-
import type { RunnerTask, Vitest } from 'vitest'
10+
import type { RunnerTask, RunnerTestFile } from 'vitest'
1211
import { DefaultReporter, type Reporter } from 'vitest/reporters'
1312

1413
/**
@@ -34,7 +33,8 @@ class VerboseReporter extends DefaultReporter implements Reporter {
3433
* Create a new verbose reporter.
3534
*/
3635
constructor() {
37-
super({ summary: false })
36+
super({ summary: true })
37+
3838
this.colors = colors
3939
this.renderSucceed = true
4040
this.verbose = true
@@ -98,33 +98,26 @@ class VerboseReporter extends DefaultReporter implements Reporter {
9898
}
9999

100100
/**
101-
* Capture end time once all tests have finished running.
102-
*
103-
* @public
104-
* @override
105-
* @instance
106-
*
107-
* @return {undefined}
108-
*/
109-
public override onFinished(): undefined {
110-
return void (this.end = performance.now())
111-
}
112-
113-
/**
114-
* Initialize the reporter.
101+
* Print tasks.
115102
*
116-
* @see {@linkcode Vitest}
103+
* @see {@linkcode RunnerTestFile}
117104
*
118105
* @public
119106
* @override
120107
* @instance
121108
*
122-
* @param {Vitest} ctx
123-
* Vitest context
109+
* @param {RunnerTestFile[] | undefined} [files]
110+
* List of test files
111+
* @param {unknown[] | undefined} [errors]
112+
* List of unhandled errors
124113
* @return {undefined}
125114
*/
126-
public override onInit(ctx: Vitest): undefined {
127-
return void (this.ctx = ctx, this.start = performance.now())
115+
public override onFinished(
116+
files?: RunnerTestFile[] | undefined,
117+
errors?: unknown[] | undefined
118+
): undefined {
119+
if (files) { for (const task of files) this.printTask(task, true) }
120+
return void super.onFinished(files, errors)
128121
}
129122

130123
/**

0 commit comments

Comments
 (0)