Skip to content

Commit

Permalink
fix: report coverage even when no tests found (#3091)
Browse files Browse the repository at this point in the history
  • Loading branch information
AriPerkkio committed Mar 28, 2023
1 parent 0f44d2c commit 2cb9121
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/node/config.ts
Expand Up @@ -268,7 +268,7 @@ export function resolveConfig(
}

export function isBrowserEnabled(config: ResolvedConfig) {
if (config.browser.enabled)
if (config.browser?.enabled)
return true

return config.poolMatchGlobs?.length && config.poolMatchGlobs.some(([, pool]) => pool === 'browser')
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/node/core.ts
Expand Up @@ -266,6 +266,7 @@ export class Vitest {
if (!files.length) {
const exitCode = this.config.passWithNoTests ? 0 : 1

await this.reportCoverage(true)
this.logger.printNoTestFound(filters)

process.exit(exitCode)
Expand Down
4 changes: 3 additions & 1 deletion test/coverage-test/testing.mjs
Expand Up @@ -44,8 +44,10 @@ for (const threads of [{ threads: true }, { threads: false }, { singleThread: tr
isolate,
})

if (process.exitCode)
if (process.exitCode) {
console.error(`process.exitCode was set to ${process.exitCode}, exiting.`)
exit()
}
}
}
}
Expand Down

0 comments on commit 2cb9121

Please sign in to comment.