From 4d5597df7b343a444329d9f789fbb3a4b22d5cbc Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 8 Jul 2024 17:10:41 +0200 Subject: [PATCH] fix(vitest): print only running files, not every file (#6052) --- packages/runner/src/types/tasks.ts | 4 ++++ packages/vitest/src/node/state.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/runner/src/types/tasks.ts b/packages/runner/src/types/tasks.ts index bdd09f32b4fc..706cb75e4d71 100644 --- a/packages/runner/src/types/tasks.ts +++ b/packages/runner/src/types/tasks.ts @@ -68,6 +68,10 @@ export interface File extends Suite { projectName: string | undefined collectDuration?: number setupDuration?: number + /** + * Whether the file is initiated without running any tests. + */ + local?: boolean } export interface Test extends TaskPopulated { diff --git a/packages/vitest/src/node/state.ts b/packages/vitest/src/node/state.ts index 4b9cf1ed9f85..919af2bc6f0e 100644 --- a/packages/vitest/src/node/state.ts +++ b/packages/vitest/src/node/state.ts @@ -69,14 +69,17 @@ export class StateManager { return Array.from(this.pathsSet) } + /** + * Return files that were running or collected. + */ getFiles(keys?: string[]): File[] { if (keys) { return keys .map(key => this.filesMap.get(key)!) - .filter(Boolean) .flat() + .filter(file => file && !file.local) } - return Array.from(this.filesMap.values()).flat() + return Array.from(this.filesMap.values()).flat().filter(file => !file.local) } getFilepaths(): string[] { @@ -128,6 +131,7 @@ export class StateManager { project.config.root, project.config.name, ) + fileTask.local = true this.idMap.set(fileTask.id, fileTask) if (!files) { this.filesMap.set(path, [fileTask])