Skip to content

Commit 8cab960

Browse files
authoredJan 14, 2025··
fix: colors on forks pool (#7090)
1 parent 798c0da commit 8cab960

File tree

14 files changed

+71
-36
lines changed

14 files changed

+71
-36
lines changed
 

‎packages/browser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"magic-string": "^0.30.17",
9595
"msw": "^2.7.0",
9696
"sirv": "^3.0.0",
97-
"tinyrainbow": "^1.2.0",
97+
"tinyrainbow": "^2.0.0",
9898
"ws": "^8.18.0"
9999
},
100100
"devDependencies": {

‎packages/coverage-istanbul/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"istanbul-reports": "^3.1.7",
5454
"magicast": "^0.3.5",
5555
"test-exclude": "^7.0.1",
56-
"tinyrainbow": "^1.2.0"
56+
"tinyrainbow": "^2.0.0"
5757
},
5858
"devDependencies": {
5959
"@types/debug": "^4.1.12",

‎packages/coverage-v8/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"magicast": "^0.3.5",
6666
"std-env": "^3.8.0",
6767
"test-exclude": "^7.0.1",
68-
"tinyrainbow": "^1.2.0"
68+
"tinyrainbow": "^2.0.0"
6969
},
7070
"devDependencies": {
7171
"@types/debug": "^4.1.12",

‎packages/expect/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"@vitest/spy": "workspace:*",
3838
"@vitest/utils": "workspace:*",
3939
"chai": "^5.1.2",
40-
"tinyrainbow": "^1.2.0"
40+
"tinyrainbow": "^2.0.0"
4141
},
4242
"devDependencies": {
4343
"@types/chai": "4.3.6",

‎packages/pretty-format/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dev": "rollup -c --watch"
3535
},
3636
"dependencies": {
37-
"tinyrainbow": "^1.2.0"
37+
"tinyrainbow": "^2.0.0"
3838
},
3939
"devDependencies": {
4040
"@types/react-is": "^19.0.0",

‎packages/ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"pathe": "^2.0.0",
5454
"sirv": "^3.0.0",
5555
"tinyglobby": "^0.2.10",
56-
"tinyrainbow": "^1.2.0"
56+
"tinyrainbow": "^2.0.0"
5757
},
5858
"devDependencies": {
5959
"@faker-js/faker": "^9.3.0",

‎packages/utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"dependencies": {
6767
"@vitest/pretty-format": "workspace:*",
6868
"loupe": "^3.1.2",
69-
"tinyrainbow": "^1.2.0"
69+
"tinyrainbow": "^2.0.0"
7070
},
7171
"devDependencies": {
7272
"@jridgewell/trace-mapping": "^0.3.25",

‎packages/vite-node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@
9191
"devDependencies": {
9292
"@jridgewell/trace-mapping": "^0.3.25",
9393
"@types/debug": "^4.1.12",
94-
"tinyrainbow": "^1.2.0"
94+
"tinyrainbow": "^2.0.0"
9595
}
9696
}

‎packages/vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
"tinybench": "^2.9.0",
167167
"tinyexec": "^0.3.2",
168168
"tinypool": "^1.0.2",
169-
"tinyrainbow": "^1.2.0",
169+
"tinyrainbow": "^2.0.0",
170170
"vite": "^5.0.0 || ^6.0.0",
171171
"vite-node": "workspace:*",
172172
"why-is-node-running": "^2.3.0"

‎packages/vitest/src/node/pool.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Vitest } from './core'
33
import type { TestProject } from './project'
44
import type { TestSpecification } from './spec'
55
import type { BuiltinPool, Pool } from './types/pool-options'
6+
import { isatty } from 'node:tty'
67
import mm from 'micromatch'
78
import { isWindows } from '../utils/env'
89
import { createForksPool } from './pools/forks'
@@ -124,6 +125,7 @@ export function createPool(ctx: Vitest): ProcessPool {
124125
VITEST: 'true',
125126
NODE_ENV: process.env.NODE_ENV || 'test',
126127
VITEST_MODE: ctx.config.watch ? 'WATCH' : 'RUN',
128+
FORCE_TTY: isatty(1) ? 'true' : '',
127129
...process.env,
128130
...ctx.config.env,
129131
},

‎pnpm-lock.yaml

+25-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/config/test/console-color.test.ts

+33
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect, test } from 'vitest'
2+
import { isWindows } from '../../../packages/vite-node/src/utils'
23
import { runVitest } from '../../test-utils'
34

45
test('with color', async () => {
@@ -29,3 +30,35 @@ test('without color', async () => {
2930
expect(stdout).toContain('true\n')
3031
expect(stdout).not.toContain('\x1B[33mtrue\x1B[39m\n')
3132
})
33+
34+
test.skipIf(isWindows)('without color, forks pool in non-TTY parent', async () => {
35+
const { stdout } = await runVitest({
36+
root: 'fixtures/console-color',
37+
env: {
38+
CI: undefined,
39+
FORCE_COLOR: undefined,
40+
NO_COLOR: undefined,
41+
GITHUB_ACTIONS: undefined,
42+
43+
// Overrides current process's value, since we are running Vitest in Vitest here
44+
FORCE_TTY: undefined,
45+
},
46+
}, undefined, undefined, undefined, { preserveAnsi: true })
47+
48+
expect(stdout).toContain('true\n')
49+
expect(stdout).not.toContain('\x1B[33mtrue\x1B[39m\n')
50+
})
51+
52+
test('with color, forks pool in TTY parent', async () => {
53+
const { stdout } = await runVitest({
54+
root: 'fixtures/console-color',
55+
env: {
56+
CI: undefined,
57+
FORCE_COLOR: undefined,
58+
NO_COLOR: undefined,
59+
GITHUB_ACTIONS: undefined,
60+
},
61+
}, undefined, undefined, undefined, { preserveAnsi: true })
62+
63+
expect(stdout).toContain('\x1B[33mtrue\x1B[39m\n')
64+
})

‎test/core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"react": "^18.3.1",
3131
"react-19": "npm:react@19.0.0-rc-b01722d5-20241114",
3232
"sweetalert2": "^11.6.16",
33-
"tinyrainbow": "^1.2.0",
33+
"tinyrainbow": "^2.0.0",
3434
"tinyspy": "^1.0.2",
3535
"url": "^0.11.0",
3636
"vite-node": "workspace:*",

‎test/test-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"devDependencies": {
1010
"tinyexec": "^0.3.2",
11-
"tinyrainbow": "^1.2.0",
11+
"tinyrainbow": "^2.0.0",
1212
"vite": "latest",
1313
"vite-node": "workspace:*",
1414
"vitest": "workspace:*"

0 commit comments

Comments
 (0)
Please sign in to comment.