Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test_runner: handled change for exposing 'spec' reporter
Other reporters (dot, tap) by signature are a function while 'spec' reporter is a ES6 class.

This behaviour of api spec is causing difference in semantics while consumption since it has not been addressed anywhere in the document (it has to be instantiated).

Instead of making changes in the signature of spec.js, i have proposed changes where the 'spec' reporter gets exposed in reporter.js

Fixes: #48112
Refs: https://github.com/nodejs/node/blob/main/lib/internal/test_runner/reporter/spec.js
Refs: (@line-no:143) https://github.com/nodejs/node/blob/main/lib/internal/test_runner/utils.js
  • Loading branch information
Sumi0 committed May 27, 2023
commit 4ebfc7b8552f397bdc27da5bbf2fb3656831099e
4 changes: 2 additions & 2 deletions lib/test/reporters.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { ObjectDefineProperties } = primordials;
const { ObjectDefineProperties, ReflectConstruct } = primordials;

let dot;
let spec;
Expand All @@ -22,7 +22,7 @@ ObjectDefineProperties(module.exports, {
configurable: true,
enumerable: true,
get() {
Comment thread
Sumi0 marked this conversation as resolved.
Outdated
spec ??= require('internal/test_runner/reporter/spec');
spec ??= (...args) => ReflectConstruct(require('internal/test_runner/reporter/spec'), args);
Comment thread
Sumi0 marked this conversation as resolved.
Outdated
return spec;
},
},
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
Expand Down