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

Pro-actively write out code coverage #3220

Merged
merged 1 commit into from Jul 2, 2023
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: 7 additions & 0 deletions lib/cli.js
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';
import v8 from 'node:v8';

import arrify from 'arrify';
import figures from 'figures';
Expand Down Expand Up @@ -474,6 +475,12 @@ export default async function loadCli() { // eslint-disable-line complexity
reporter.startRun(plan);

plan.status.on('stateChange', evt => {
if (evt.type === 'end' || evt.type === 'interrupt') {
// Write out code coverage data when the run ends, lest a process
// interrupt causes it to be lost.
v8.takeCoverage();
}

if (evt.type === 'interrupt') {
reporter.endRun();
process.exit(1); // eslint-disable-line unicorn/no-process-exit
Expand Down