Skip to content

Commit 2cb9121

Browse files
authoredMar 28, 2023
fix: report coverage even when no tests found (#3091)
1 parent 0f44d2c commit 2cb9121

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed
 

‎packages/vitest/src/node/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export function resolveConfig(
268268
}
269269

270270
export function isBrowserEnabled(config: ResolvedConfig) {
271-
if (config.browser.enabled)
271+
if (config.browser?.enabled)
272272
return true
273273

274274
return config.poolMatchGlobs?.length && config.poolMatchGlobs.some(([, pool]) => pool === 'browser')

‎packages/vitest/src/node/core.ts

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ export class Vitest {
266266
if (!files.length) {
267267
const exitCode = this.config.passWithNoTests ? 0 : 1
268268

269+
await this.reportCoverage(true)
269270
this.logger.printNoTestFound(filters)
270271

271272
process.exit(exitCode)

‎test/coverage-test/testing.mjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ for (const threads of [{ threads: true }, { threads: false }, { singleThread: tr
4444
isolate,
4545
})
4646

47-
if (process.exitCode)
47+
if (process.exitCode) {
48+
console.error(`process.exitCode was set to ${process.exitCode}, exiting.`)
4849
exit()
50+
}
4951
}
5052
}
5153
}

0 commit comments

Comments
 (0)
Please sign in to comment.