MCPcopy Index your code
hub / github.com/nodejs/node / getReportersMap

Function getReportersMap

lib/internal/test_runner/utils.js:200–235  ·  view source on GitHub ↗
(reporters, destinations)

Source from the content-addressed store, hash-verified

198}
199
200async function getReportersMap(reporters, destinations) {
201 return SafePromiseAllReturnArrayLike(reporters, async (name, i) => {
202 const destination = kBuiltinDestinations.get(destinations[i]) ??
203 createWriteStream(destinations[i], { __proto__: null, flush: true });
204
205 // Load the test reporter passed to --test-reporter
206 let reporter = tryBuiltinReporter(name);
207
208 if (reporter === undefined) {
209 let parentURL;
210
211 try {
212 parentURL = pathToFileURL(process.cwd() + '/').href;
213 } catch {
214 parentURL = 'file:///';
215 }
216
217 const cascadedLoader = require('internal/modules/esm/loader').getOrInitializeCascadedLoader();
218 reporter = await cascadedLoader.import(name, parentURL, { __proto__: null });
219 }
220
221 if (reporter?.default) {
222 reporter = reporter.default;
223 }
224
225 if (reporter?.prototype && ObjectGetOwnPropertyDescriptor(reporter.prototype, 'constructor')) {
226 reporter = new reporter();
227 }
228
229 if (!reporter) {
230 throw new ERR_INVALID_ARG_VALUE('Reporter', name, 'is not a valid reporter');
231 }
232
233 return { __proto__: null, reporter, destination };
234 });
235}
236
237const reporterScope = new AsyncResource('TestReporterScope');
238const testChannel = tracingChannel('node.test');

Callers 1

parseCommandLineFunction · 0.85

Calls 6

tryBuiltinReporterFunction · 0.85
importMethod · 0.80
getMethod · 0.65
createWriteStreamFunction · 0.50
pathToFileURLFunction · 0.50
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…