| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a49e17e commit 8b473af
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,28 +92,43 @@ const kBuiltinDestinations = new SafeMap([ | |||
| 92 | 92 | ]); | |
| 93 | 93 | ||
| 94 | 94 | const kBuiltinReporters = new SafeMap([ | |
| 95 | - ['spec', 'node:test/reporter/spec'], | ||
| 96 | - ['dot', 'node:test/reporter/dot'], | ||
| 97 | - ['tap', 'node:test/reporter/tap'], | ||
| 95 | + ['spec', 'internal/test_runner/reporter/spec'], | ||
| 96 | + ['dot', 'internal/test_runner/reporter/dot'], | ||
| 97 | + ['tap', 'internal/test_runner/reporter/tap'], | ||
| 98 | 98 | ]); | |
| 99 | 99 | ||
| 100 | 100 | const kDefaultReporter = 'tap'; | |
| 101 | 101 | const kDefaultDestination = 'stdout'; | |
| 102 | 102 | ||
| 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 | + | ||
| 103 | 113 | async function getReportersMap(reporters, destinations) { | |
| 104 | 114 | return SafePromiseAllReturnArrayLike(reporters, async (name, i) => { | |
| 105 | 115 | const destination = kBuiltinDestinations.get(destinations[i]) ?? createWriteStream(destinations[i]); | |
| 106 | 116 | ||
| 107 | 117 | // Load the test reporter passed to --test-reporter | |
| 108 | - const reporterSpecifier = kBuiltinReporters.get(name) ?? name; | ||
| 109 | - let parentURL; | ||
| 110 | - try { | ||
| 111 | - parentURL = pathToFileURL(process.cwd() + '/').href; | ||
| 112 | - } catch { | ||
| 113 | - parentURL = 'file:///'; | ||
| 118 | + let reporter = tryBuiltinReporter(name); | ||
| 119 | + | ||
| 120 | + if (reporter === undefined) { | ||
| 121 | + let parentURL; | ||
| 122 | + | ||
| 123 | + try { | ||
| 124 | + parentURL = pathToFileURL(process.cwd() + '/').href; | ||
| 125 | + } catch { | ||
| 126 | + parentURL = 'file:///'; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + const { esmLoader } = require('internal/process/esm_loader'); | ||
| 130 | + reporter = await esmLoader.import(name, parentURL, { __proto__: null }); | ||
| 114 | 131 | } | |
| 115 | - const { esmLoader } = require('internal/process/esm_loader'); | ||
| 116 | - let reporter = await esmLoader.import(reporterSpecifier, parentURL, { __proto__: null }); | ||
| 117 | 132 | ||
| 118 | 133 | if (reporter?.default) { | |
| 119 | 134 | reporter = reporter.default; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments