diff --git a/lib/test/reporters.js b/lib/test/reporters.js index 287c07510bc13a..33d9991022d1c9 100644 --- a/lib/test/reporters.js +++ b/lib/test/reporters.js @@ -1,6 +1,6 @@ 'use strict'; -const { ObjectDefineProperties } = primordials; +const { ObjectDefineProperties, ReflectConstruct } = primordials; let dot; let spec; @@ -21,9 +21,8 @@ ObjectDefineProperties(module.exports, { __proto__: null, configurable: true, enumerable: true, - get() { - spec ??= require('internal/test_runner/reporter/spec'); - return spec; + value: spec ?? function SpecReporter() { + return ReflectConstruct(require('internal/test_runner/reporter/spec'), arguments); }, }, tap: { diff --git a/test/parallel/test-runner-run.mjs b/test/parallel/test-runner-run.mjs index 794d55ab1a51d1..107067053881fd 100644 --- a/test/parallel/test-runner-run.mjs +++ b/test/parallel/test-runner-run.mjs @@ -76,8 +76,7 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { }); it('should be piped with spec', async () => { - const specReporter = new spec(); - const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(specReporter).toArray(); + const result = await run({ files: [join(testFixtures, 'test/random.cjs')] }).compose(spec).toArray(); const stringResults = result.map((bfr) => bfr.toString()); assert.match(stringResults[0], /this should pass/); assert.match(stringResults[1], /tests 1/);