| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 23d310b commit 2b797a6
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1519,6 +1519,24 @@ Emitted when all subtests have completed for a given test. | |||
| 1519 | 1519 | ||
| 1520 | 1520 | Emitted when a test starts. | |
| 1521 | 1521 | ||
| 1522 | + ### Event: `'test:stderr'` | ||
| 1523 | + | ||
| 1524 | + * `data` {Object} | ||
| 1525 | + * `file` {string} The path of the test file. | ||
| 1526 | + * `message` {string} The message written to `stderr`. | ||
| 1527 | + | ||
| 1528 | + Emitted when a running test writes to `stderr`. | ||
| 1529 | + This event is only emitted if `--test` flag is passed. | ||
| 1530 | + | ||
| 1531 | + ### Event: `'test:stdout'` | ||
| 1532 | + | ||
| 1533 | + * `data` {Object} | ||
| 1534 | + * `file` {string} The path of the test file. | ||
| 1535 | + * `message` {string} The message written to `stdout`. | ||
| 1536 | + | ||
| 1537 | + Emitted when a running test writes to `stdout`. | ||
| 1538 | + This event is only emitted if `--test` flag is passed. | ||
| 1539 | + | ||
| 1522 | 1540 | ## Class: `TestContext` | |
| 1523 | 1541 | ||
| 1524 | 1542 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,6 +117,9 @@ class SpecReporter extends Transform { | |||
| 117 | 117 | case 'test:start': | |
| 118 | 118 | ArrayPrototypeUnshift(this.#stack, { __proto__: null, data, type }); | |
| 119 | 119 | break; | |
| 120 | + case 'test:stderr': | ||
| 121 | + case 'test:stdout': | ||
| 122 | + return `${data.message}\n`; | ||
| 120 | 123 | case 'test:diagnostic': | |
| 121 | 124 | return `${colors[type]}${this.#indent(data.nesting)}${symbols[type]}${data.message}${white}\n`; | |
| 122 | 125 | case 'test:coverage': | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,6 +45,8 @@ async function * tapReporter(source) { | |||
| 45 | 45 | case 'test:start': | |
| 46 | 46 | yield `${indent(data.nesting)}# Subtest: ${tapEscape(data.name)}\n`; | |
| 47 | 47 | break; | |
| 48 | + case 'test:stderr': | ||
| 49 | + case 'test:stdout': | ||
| 48 | 50 | case 'test:diagnostic': | |
| 49 | 51 | yield `${indent(data.nesting)}# ${tapEscape(data.message)}\n`; | |
| 50 | 52 | break; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -285,8 +285,8 @@ class FileTest extends Test { | |||
| 285 | 285 | const message = messages[i]; | |
| 286 | 286 | this.addToReport({ | |
| 287 | 287 | __proto__: null, | |
| 288 | - type: 'test:diagnostic', | ||
| 289 | - data: { __proto__: null, nesting: 0, file: this.name, message }, | ||
| 288 | + type: 'test:stdout', | ||
| 289 | + data: { __proto__: null, file: this.name, message }, | ||
| 290 | 290 | }); | |
| 291 | 291 | } | |
| 292 | 292 | } | |
@@ -357,13 +357,12 @@ function runTestFile(path, root, inspectPort, filesWatcher, testNamePatterns) { | |||
| 357 | 357 | } | |
| 358 | 358 | ||
| 359 | 359 | // stderr cannot be treated as TAP, per the spec. However, we want to | |
| 360 | - // surface stderr lines as TAP diagnostics to improve the DX. Inject | ||
| 361 | - // each line into the test output as an unknown token as if it came | ||
| 362 | - // from the TAP parser. | ||
| 360 | + // surface stderr lines to improve the DX. Inject each line into the | ||
| 361 | + // test output as an unknown token as if it came from the TAP parser. | ||
| 363 | 362 | subtest.addToReport({ | |
| 364 | 363 | __proto__: null, | |
| 365 | - type: 'test:diagnostic', | ||
| 366 | - data: { __proto__: null, nesting: 0, file: path, message: line }, | ||
| 364 | + type: 'test:stderr', | ||
| 365 | + data: { __proto__: null, file: path, message: line }, | ||
| 367 | 366 | }); | |
| 368 | 367 | }); | |
| 369 | 368 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,6 +57,14 @@ class TestsStream extends Readable { | |||
| 57 | 57 | this[kEmitMessage]('test:diagnostic', { __proto__: null, nesting, file, message }); | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | + stderr(file, message) { | ||
| 61 | + this[kEmitMessage]('test:stderr', { __proto__: null, file, message }); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + stdout(file, message) { | ||
| 65 | + this[kEmitMessage]('test:stdout', { __proto__: null, file, message }); | ||
| 66 | + } | ||
| 67 | + | ||
| 60 | 68 | coverage(nesting, file, summary) { | |
| 61 | 69 | this[kEmitMessage]('test:coverage', { __proto__: null, nesting, file, summary }); | |
| 62 | 70 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments