Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make takeCoverage call optional (fix #670) #672

Merged
merged 1 commit into from Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/vitest/src/integrations/coverage.ts
@@ -1,5 +1,4 @@
import { existsSync, promises as fs } from 'fs'
import { takeCoverage } from 'v8'
import { createRequire } from 'module'
import { pathToFileURL } from 'url'
import type { Profiler } from 'inspector'
Expand Down Expand Up @@ -57,7 +56,11 @@ const require = createRequire(import.meta.url)

export async function reportCoverage(ctx: Vitest) {
// Flush coverage to disk
takeCoverage()
const v8 = require('v8')
if (v8.takeCoverage == null)
console.warn('[Vitest] takeCoverage is not available in this NodeJs version.\nCoverage could be incomplete. Update to NodeJs 14.18.')
else
v8.takeCoverage()

// eslint-disable-next-line @typescript-eslint/no-var-requires
const createReport = require('c8/lib/report')
Expand Down