Skip to content

Commit 95cc98e

Browse files
atlowChemitargos
authored andcommitted
test_runner: expose spec reporter as newable function
Fixes: #48112 Ref: #48208 PR-URL: #49184 Refs: #48208 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent d839640 commit 95cc98e

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

‎lib/test/reporters.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const{ ObjectDefineProperties }=primordials;
3+
const{ ObjectDefineProperties, ReflectConstruct}=primordials;
44

55
letdot;
66
letspec;
@@ -21,9 +21,9 @@ ObjectDefineProperties(module.exports,{
2121
__proto__: null,
2222
configurable: true,
2323
enumerable: true,
24-
get(){
24+
value: functionvalue(){
2525
spec??=require('internal/test_runner/reporter/spec');
26-
returnspec;
26+
returnReflectConstruct(spec,arguments);
2727
},
2828
},
2929
tap: {

‎test/parallel/test-runner-run.mjs‎

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,28 @@ describe('require(\'node:test\').run',{concurrency: true }, () =>{
8282
]);
8383
});
8484

85-
it('should be piped with spec',async()=>{
86-
constspecReporter=newspec();
87-
constresult=awaitrun({
88-
files: [join(testFixtures,'default-behavior/test/random.cjs')]
89-
}).compose(specReporter).toArray();
90-
conststringResults=result.map((bfr)=>bfr.toString());
91-
assert.match(stringResults[0],/thisshouldpass/);
92-
assert.match(stringResults[1],/tests1/);
93-
assert.match(stringResults[1],/pass1/);
85+
describe('should be piped with spec reporter',()=>{
86+
it('new spec',async()=>{
87+
constspecReporter=newspec();
88+
constresult=awaitrun({
89+
files: [join(testFixtures,'default-behavior/test/random.cjs')]
90+
}).compose(specReporter).toArray();
91+
conststringResults=result.map((bfr)=>bfr.toString());
92+
assert.match(stringResults[0],/thisshouldpass/);
93+
assert.match(stringResults[1],/tests1/);
94+
assert.match(stringResults[1],/pass1/);
95+
});
96+
97+
it('spec()',async()=>{
98+
constspecReporter=spec();
99+
constresult=awaitrun({
100+
files: [join(testFixtures,'default-behavior/test/random.cjs')]
101+
}).compose(specReporter).toArray();
102+
conststringResults=result.map((bfr)=>bfr.toString());
103+
assert.match(stringResults[0],/thisshouldpass/);
104+
assert.match(stringResults[1],/tests1/);
105+
assert.match(stringResults[1],/pass1/);
106+
});
94107
});
95108

96109
it('should be piped with tap',async()=>{

0 commit comments

Comments
(0)