| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,17 +1,27 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | + const { MathMax } = primordials; | ||
| 2 | 3 | ||
| 3 | 4 | module.exports = async function* dot(source) { | |
| 4 | 5 | let count = 0; | |
| 6 | + let columns = getLineLength(); | ||
| 5 | 7 | for await (const { type } of source) { | |
| 6 | 8 | if (type === 'test:pass') { | |
| 7 | 9 | yield '.'; | |
| 8 | 10 | } | |
| 9 | 11 | if (type === 'test:fail') { | |
| 10 | 12 | yield 'X'; | |
| 11 | 13 | } | |
| 12 | - if ((type === 'test:fail' || type === 'test:pass') && ++count % 20 === 0) { | ||
| 14 | + if ((type === 'test:fail' || type === 'test:pass') && ++count === columns) { | ||
| 13 | 15 | yield '\n'; | |
| 16 | + | ||
| 17 | + // Getting again in case the terminal was resized. | ||
| 18 | + columns = getLineLength(); | ||
| 19 | + count = 0; | ||
| 14 | 20 | } | |
| 15 | 21 | } | |
| 16 | 22 | yield '\n'; | |
| 17 | 23 | }; | |
| 24 | + | ||
| 25 | + function getLineLength() { | ||
| 26 | + return MathMax(process.stdout.columns ?? 20, 20); | ||
| 27 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + // Flags: --test-reporter=dot | ||
| 2 | + 'use strict'; | ||
| 3 | + process.stdout.columns = 30; | ||
| 4 | + | ||
| 5 | + const test = require('node:test'); | ||
| 6 | + const { setTimeout } = require('timers/promises'); | ||
| 7 | + | ||
| 8 | + for (let i = 0; i < 100; i++) { | ||
| 9 | + test(i + ' example', async () => { | ||
| 10 | + if (i === 0) { | ||
| 11 | + // So the reporter will run before all tests has started | ||
| 12 | + await setTimeout(10); | ||
| 13 | + } | ||
| 14 | + // resize | ||
| 15 | + if (i === 28) | ||
| 16 | + process.stdout.columns = 41; | ||
| 17 | + }); | ||
| 18 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,3 @@ | |||
| 1 | + .............................. | ||
| 2 | + ......................................... | ||
| 3 | + ............................. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,7 @@ const tests = [ | |||
| 46 | 46 | { name: 'test-runner/output/unresolved_promise.js' }, | |
| 47 | 47 | { name: 'test-runner/output/default_output.js', transform: specTransform, tty: true }, | |
| 48 | 48 | { name: 'test-runner/output/arbitrary-output.js' }, | |
| 49 | + { name: 'test-runner/output/dot_output_custom_columns.js', transform: specTransform, tty: true }, | ||
| 49 | 50 | ].map(({ name, tty, transform }) => ({ | |
| 50 | 51 | name, | |
| 51 | 52 | fn: common.mustCall(async () => { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments