This is a breaking change for the format of test:coverage events. But the test coverage is still experimental, so I don't believe it requires a semver-major bump. Fixes https://github.com/nodejs/node/issues/49303 PR-URL: https://github.com/nodejs/node/pull/49320 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
15 lines
374 B
JavaScript
15 lines
374 B
JavaScript
import { Transform } from 'node:stream';
|
|
|
|
export default class CoverageReporter extends Transform {
|
|
constructor(options) {
|
|
super({ ...options, writableObjectMode: true });
|
|
}
|
|
|
|
_transform(event, _encoding, callback) {
|
|
if (event.type === 'test:coverage') {
|
|
callback(null, JSON.stringify(event.data, null, 2));
|
|
} else {
|
|
callback(null);
|
|
}
|
|
}
|
|
}
|