diff --git a/packages/vite/src/executors/test/vitest.impl.ts b/packages/vite/src/executors/test/vitest.impl.ts index 898e49a52bdeb..302c23a609cb9 100644 --- a/packages/vite/src/executors/test/vitest.impl.ts +++ b/packages/vite/src/executors/test/vitest.impl.ts @@ -58,7 +58,10 @@ export async function* vitestExecutor( } // vitest sets the exitCode in case of exception without notifying reporters - if (process.exitCode === undefined) { + if ( + process.exitCode === undefined || + (watch && ctx.state.getFiles().length > 0) + ) { for await (const report of nxReporter) { // vitest sets the exitCode = 1 when code coverage isn't met hasErrors =