diff --git a/packages/vitest/src/node/core.ts b/packages/vitest/src/node/core.ts index cb57de591df9..2cd058f64cb2 100644 --- a/packages/vitest/src/node/core.ts +++ b/packages/vitest/src/node/core.ts @@ -160,10 +160,14 @@ export class Vitest { checker.onParseEnd(async ({ files, sourceErrors }) => { this.state.collectFiles(checker.getTestFiles()) await this.report('onCollected') - if (!files.length) + if (!files.length) { this.logger.printNoTestFound() - else + } + else { + if (hasFailed(files)) + process.exitCode = 1 await this.report('onFinished', files) + } if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) { process.exitCode = 1 await this.logger.printSourceTypeErrors(sourceErrors)