| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1ec1348 commit a5e0e9e
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -447,7 +447,7 @@ The following built-reporters are supported: | |||
| 447 | 447 | The `spec` reporter outputs the test results in a human-readable format. | |
| 448 | 448 | ||
| 449 | 449 | * `dot` | |
| 450 | - The `dot` reporter outputs the test results in a comact format, | ||
| 450 | + The `dot` reporter outputs the test results in a compact format, | ||
| 451 | 451 | where each passing test is represented by a `.`, | |
| 452 | 452 | and each failing test is represented by a `X`. | |
| 453 | 453 | ||
@@ -564,6 +564,9 @@ module.exports = async function * customReporter(source) { | |||
| 564 | 564 | }; | |
| 565 | 565 | ``` | |
| 566 | 566 | ||
| 567 | + The value provided to `--test-reporter` should be a string like one used in an | ||
| 568 | + `import()` in JavaScript code, or a value provided for [`--import`][]. | ||
| 569 | + | ||
| 567 | 570 | ### Multiple reporters | |
| 568 | 571 | ||
| 569 | 572 | The [`--test-reporter`][] flag can be specified multiple times to report test | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // https://github.com/nodejs/node/blob/a1b27b25bb01aadd3fd2714e4b136db11b7eb85a/lib/internal/test_runner/utils.js | ||
| 1 | + // https://github.com/nodejs/node/blob/12c0571c8fece32d274eaf0ae197c0eb1948fe11/lib/internal/test_runner/utils.js | ||
| 2 | 2 | 'use strict' | |
| 3 | 3 | const { | |
| 4 | 4 | ArrayPrototypePush, | |
@@ -103,7 +103,10 @@ const kDefaultDestination = 'stdout' | |||
| 103 | 103 | async function getReportersMap (reporters, destinations) { | |
| 104 | 104 | return SafePromiseAllReturnArrayLike(reporters, async (name, i) => { | |
| 105 | 105 | const destination = kBuiltinDestinations.get(destinations[i]) ?? createWriteStream(destinations[i]) | |
| 106 | - let reporter = await import(kBuiltinReporters.get(name) ?? name) | ||
| 106 | + | ||
| 107 | + // Load the test reporter passed to --test-reporter | ||
| 108 | + const reporterSpecifier = kBuiltinReporters.get(name) ?? name | ||
| 109 | + let reporter = await import(reporterSpecifier) | ||
| 107 | 110 | ||
| 108 | 111 | if (reporter?.default) { | |
| 109 | 112 | reporter = reporter.default | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,19 @@ | |||
| 1 | - // https://github.com/nodejs/node/blob/1aab13cad9c800f4121c1d35b554b78c1b17bdbd/test/common/fixtures.js | ||
| 1 | + // https://github.com/nodejs/node/blob/12c0571c8fece32d274eaf0ae197c0eb1948fe11/test/common/fixtures.js | ||
| 2 | 2 | 'use strict' | |
| 3 | 3 | ||
| 4 | 4 | const path = require('path') | |
| 5 | + const { pathToFileURL } = require('url') | ||
| 5 | 6 | ||
| 6 | 7 | const fixturesDir = path.join(__dirname, '..', 'fixtures') | |
| 7 | 8 | ||
| 8 | 9 | function fixturesPath (...args) { | |
| 9 | 10 | return path.join(fixturesDir, ...args) | |
| 10 | 11 | } | |
| 12 | + function fixturesFileURL (...args) { | ||
| 13 | + return pathToFileURL(fixturesPath(...args)) | ||
| 14 | + } | ||
| 11 | 15 | ||
| 12 | 16 | module.exports = { | |
| 13 | - path: fixturesPath | ||
| 17 | + path: fixturesPath, | ||
| 18 | + fileURL: fixturesFileURL | ||
| 14 | 19 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // https://github.com/nodejs/node/blob/a1b27b25bb01aadd3fd2714e4b136db11b7eb85a/test/parallel/test-runner-reporters.js | ||
| 1 | + // https://github.com/nodejs/node/blob/12c0571c8fece32d274eaf0ae197c0eb1948fe11/test/parallel/test-runner-reporters.js | ||
| 2 | 2 | 'use strict' | |
| 3 | 3 | ||
| 4 | 4 | require('../common') | |
@@ -91,10 +91,12 @@ describe('node:test reporters', { concurrency: true }, () => { | |||
| 91 | 91 | it(`should support a '${ext}' file as a custom reporter`, async () => { | |
| 92 | 92 | const filename = `custom.${ext}` | |
| 93 | 93 | const child = spawnSync(process.execPath, | |
| 94 | - ['--test', '--test-reporter', fixtures.path('test-runner/custom_reporters/', filename), | ||
| 94 | + ['--test', '--test-reporter', fixtures.fileURL('test-runner/custom_reporters/', filename), | ||
| 95 | 95 | testFile]) | |
| 96 | 96 | assert.strictEqual(child.stderr.toString(), '') | |
| 97 | - assert.strictEqual(child.stdout.toString(), `${filename} {"test:start":5,"test:pass":2,"test:fail":3,"test:plan":3,"test:diagnostic":7}`) | ||
| 97 | + const stdout = child.stdout.toString() | ||
| 98 | + assert.match(stdout, /{"test:start":5,"test:pass":2,"test:fail":3,"test:plan":3,"test:diagnostic":\d+}$/) | ||
| 99 | + assert.strictEqual(stdout.slice(0, filename.length + 2), `${filename} {`) | ||
| 98 | 100 | }) | |
| 99 | 101 | }) | |
| 100 | 102 | }) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments