Skip to content

Commit d001c60

Browse files
committed
test: fix test runner colored output test
1 parent 431f32e commit d001c60

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: test/fixtures/test-runner/output/arbitrary-output-colored-1.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const test = require('node:test');
4+
45
console.log({ foo: 'bar' });
56
test('passing test', () => {
67
console.log(1);

Diff for: test/fixtures/test-runner/output/arbitrary-output-colored.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ const { once } = require('node:events');
44
const { spawn } = require('node:child_process');
55
const fixtures = require('../../../common/fixtures');
66

7+
const env = process.stdout.isTTY ? undefined : { FORCE_COLOR: 1 };
8+
79
(async function run() {
810
const test = fixtures.path('test-runner/output/arbitrary-output-colored-1.js');
9-
await once(spawn(process.execPath, ['--test', test], { stdio: 'inherit', env: { FORCE_COLOR: 1 } }), 'exit');
10-
await once(spawn(process.execPath, ['--test', '--test-reporter', 'tap', test], { stdio: 'inherit', env: { FORCE_COLOR: 1 } }), 'exit');
11+
await once(spawn(process.execPath, ['--test', test], { stdio: 'inherit', env }), 'exit');
12+
await once(spawn(process.execPath, ['--test', '--test-reporter', 'tap', test], { stdio: 'inherit', env }), 'exit');
1113
})().then(common.mustCall());

0 commit comments

Comments
 (0)