mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test_runner: expose spec reporter as newable function
Fixes: https://github.com/nodejs/node/issues/48112 Ref: https://github.com/nodejs/node/pull/48208 PR-URL: https://github.com/nodejs/node/pull/49184 Refs: https://github.com/nodejs/node/pull/48208 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
1 parent
d83964031b
commit
95cc98e14b
2 files changed
+25
-12
No files matched your search
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { ObjectDefineProperties } = primordials;
|
||||
const { ObjectDefineProperties, ReflectConstruct } = primordials;
|
||||
|
||||
let dot;
|
||||
let spec;
|
||||
@@ -21,9 +21,9 @@ ObjectDefineProperties(module.exports, {
|
||||
__proto__: null,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
value: function value() {
|
||||
spec ??= require('internal/test_runner/reporter/spec');
|
||||
return spec;
|
||||
return ReflectConstruct(spec, arguments);
|
||||
},
|
||||
},
|
||||
tap: {
|
||||
|
||||
@@ -82,15 +82,28 @@ 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, 'default-behavior/test/random.cjs')]
|
||||
}).compose(specReporter).toArray();
|
||||
const stringResults = result.map((bfr) => bfr.toString());
|
||||
assert.match(stringResults[0], /this should pass/);
|
||||
assert.match(stringResults[1], /tests 1/);
|
||||
assert.match(stringResults[1], /pass 1/);
|
||||
describe('should be piped with spec reporter', () => {
|
||||
it('new spec', async () => {
|
||||
const specReporter = new spec();
|
||||
const result = await run({
|
||||
files: [join(testFixtures, 'default-behavior/test/random.cjs')]
|
||||
}).compose(specReporter).toArray();
|
||||
const stringResults = result.map((bfr) => bfr.toString());
|
||||
assert.match(stringResults[0], /this should pass/);
|
||||
assert.match(stringResults[1], /tests 1/);
|
||||
assert.match(stringResults[1], /pass 1/);
|
||||
});
|
||||
|
||||
it('spec()', async () => {
|
||||
const specReporter = spec();
|
||||
const result = await run({
|
||||
files: [join(testFixtures, 'default-behavior/test/random.cjs')]
|
||||
}).compose(specReporter).toArray();
|
||||
const stringResults = result.map((bfr) => bfr.toString());
|
||||
assert.match(stringResults[0], /this should pass/);
|
||||
assert.match(stringResults[1], /tests 1/);
|
||||
assert.match(stringResults[1], /pass 1/);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be piped with tap', async () => {
|
||||
|
||||
Reference in new issue
Block a user