From 0db494d2771a309f1f4d28fd1c938012d4ea68f9 Mon Sep 17 00:00:00 2001 From: Ali Yusuf <17704100+AliYusuf95@users.noreply.github.com> Date: Sat, 31 Aug 2024 04:30:50 +0300 Subject: [PATCH] fix(vite): exit from test if no files found --- packages/vite/src/executors/test/vitest.impl.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/executors/test/vitest.impl.ts b/packages/vite/src/executors/test/vitest.impl.ts index 4af8a33c0a1e07..a28ab7d9110f1b 100644 --- a/packages/vite/src/executors/test/vitest.impl.ts +++ b/packages/vite/src/executors/test/vitest.impl.ts @@ -57,10 +57,15 @@ export async function* vitestExecutor( process.on('exit', processExit); } - for await (const report of nxReporter) { - // vitest sets the exitCode = 1 when code coverage isn't met - hasErrors = - report.hasErrors || (process.exitCode && process.exitCode !== 0); + // vitest sets the exitCode in case of exception without notifying reporters + if (process.exitCode === undefined) { + for await (const report of nxReporter) { + // vitest sets the exitCode = 1 when code coverage isn't met + hasErrors = + report.hasErrors || (process.exitCode && process.exitCode !== 0); + } + } else { + hasErrors = process.exitCode !== 0 } return {