|
1 | 1 | import { expect, test } from 'vitest'
|
| 2 | +import { isWindows } from '../../../packages/vite-node/src/utils' |
2 | 3 | import { runVitest } from '../../test-utils'
|
3 | 4 |
|
4 | 5 | test('with color', async () => {
|
@@ -29,3 +30,35 @@ test('without color', async () => {
|
29 | 30 | expect(stdout).toContain('true\n')
|
30 | 31 | expect(stdout).not.toContain('\x1B[33mtrue\x1B[39m\n')
|
31 | 32 | })
|
| 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 | +}) |
0 commit comments