Skip to content

Commit b6177a4

Browse files
cjihrigMoLow
authored andcommitted
fix: make built in reporters internal
This commit updates the test runner to make the built in test reporters internal modules. PR-URL: nodejs/node#46092 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> (cherry picked from commit 4788c0d2a02a2e7c7088c6f39d9f13a4209ba863)
1 parent 10d6603 commit b6177a4

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/internal/test_runner/utils.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// https://github.com/nodejs/node/blob/12c0571c8fece32d274eaf0ae197c0eb1948fe11/lib/internal/test_runner/utils.js
1+
// https://github.com/nodejs/node/blob/4788c0d2a02a2e7c7088c6f39d9f13a4209ba863/lib/internal/test_runner/utils.js
22
'use strict'
33
const {
44
ArrayPrototypePush,
@@ -100,13 +100,26 @@ const kBuiltinReporters = new SafeMap([
100100
const kDefaultReporter = 'tap'
101101
const kDefaultDestination = 'stdout'
102102

103+
function tryBuiltinReporter (name) {
104+
const builtinPath = kBuiltinReporters.get(name)
105+
106+
if (builtinPath === undefined) {
107+
return
108+
}
109+
110+
return require(builtinPath)
111+
}
112+
103113
async function getReportersMap (reporters, destinations) {
104114
return SafePromiseAllReturnArrayLike(reporters, async (name, i) => {
105115
const destination = kBuiltinDestinations.get(destinations[i]) ?? createWriteStream(destinations[i])
106116

107117
// Load the test reporter passed to --test-reporter
108-
const reporterSpecifier = kBuiltinReporters.get(name) ?? name
109-
let reporter = await import(reporterSpecifier)
118+
let reporter = tryBuiltinReporter(name)
119+
120+
if (reporter === undefined) {
121+
reporter = await import(name)
122+
}
110123

111124
if (reporter?.default) {
112125
reporter = reporter.default

0 commit comments

Comments
 (0)