node/test/fixtures/test-runner/user-logs.js
Colin Ihrig cc2732d764
test_runner: don't parse TAP from stderr
This commit stops the test runner CLI from parsing child
process stderr as TAP. Per the TAP spec, TAP can only come from
stdout. To avoid losing stderr data, those logs are injected
into the parser as unknown tokens so that they are output as
comments.

PR-URL: https://github.com/nodejs/node/pull/45618
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2022-12-02 03:12:07 +00:00

20 lines
452 B
JavaScript

'use strict';
const test = require('node:test');
console.error('stderr', 1);
test('a test', async () => {
console.error('stderr', 2);
await new Promise((resolve) => {
console.log('stdout', 3);
setTimeout(() => {
// This should not be sent to the TAP parser.
console.error('not ok 1 - fake test');
resolve();
console.log('stdout', 4);
}, 2);
});
console.error('stderr', 5);
});
console.error('stderr', 6);