fix(reporter): print test only once in the verbose mode (#7738) · vitest-dev/vitest@69ca425
@@ -502,25 +502,7 @@ export class Vitest {
502502await this._testRun.start(specifications).catch(noop)
503503504504for (const file of files) {
505-const project = this.getProjectByName(file.projectName || '')
506-await this._testRun.enqueued(project, file).catch(noop)
507-await this._testRun.collected(project, [file]).catch(noop)
508-509-const logs: UserConsoleLog[] = []
510-511-const { packs, events } = convertTasksToEvents(file, (task) => {
512-if (task.logs) {
513-logs.push(...task.logs)
514-}
515-})
516-517-logs.sort((log1, log2) => log1.time - log2.time)
518-519-for (const log of logs) {
520-await this._testRun.log(log).catch(noop)
521-}
522-523-await this._testRun.updated(packs, events).catch(noop)
505+await this._reportFileTask(file)
524506}
525507526508if (hasFailed(files)) {
@@ -538,6 +520,29 @@ export class Vitest {
538520}
539521}
540522523+/** @internal */
524+public async _reportFileTask(file: File): Promise<void> {
525+const project = this.getProjectByName(file.projectName || '')
526+await this._testRun.enqueued(project, file).catch(noop)
527+await this._testRun.collected(project, [file]).catch(noop)
528+529+const logs: UserConsoleLog[] = []
530+531+const { packs, events } = convertTasksToEvents(file, (task) => {
532+if (task.logs) {
533+logs.push(...task.logs)
534+}
535+})
536+537+logs.sort((log1, log2) => log1.time - log2.time)
538+539+for (const log of logs) {
540+await this._testRun.log(log).catch(noop)
541+}
542+543+await this._testRun.updated(packs, events).catch(noop)
544+}
545+541546async collect(filters?: string[]): Promise<TestRunResult> {
542547const files = await this.specifications.getRelevantTestSpecifications(filters)
543548