Skip to content

Commit b6c41ca

Browse files
authoredJan 23, 2023
fix(coverage): c8 to log warning when run in Stackblitz (#2735)
1 parent 482b72f commit b6c41ca

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed
 

‎packages/coverage-c8/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
},
4444
"dependencies": {
4545
"c8": "^7.12.0",
46+
"picocolors": "^1.0.0",
47+
"std-env": "^3.3.1",
4648
"vitest": "workspace:*"
4749
},
4850
"devDependencies": {

‎packages/coverage-c8/src/provider.ts

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import _url from 'url'
33
import type { Profiler } from 'inspector'
44
import { takeCoverage } from 'v8'
55
import { extname, resolve } from 'pathe'
6+
import c from 'picocolors'
7+
import { provider } from 'std-env'
68
import type { RawSourceMap } from 'vite-node'
79
import { coverageConfigDefaults } from 'vitest/config'
810
// eslint-disable-next-line no-restricted-imports
@@ -52,6 +54,9 @@ export class C8CoverageProvider implements CoverageProvider {
5254
async reportCoverage({ allTestsRun }: ReportContext = {}) {
5355
takeCoverage()
5456

57+
if (provider === 'stackblitz')
58+
this.ctx.logger.log(c.blue(' % ') + c.yellow('@vitest/coverage-c8 does not work on Stackblitz. Report will be empty.'))
59+
5560
const options: ConstructorParameters<typeof Report>[0] = {
5661
...this.options,
5762
all: this.options.all && allTestsRun,

‎pnpm-lock.yaml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.