-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: run mode stuck in TTY terminals (#3690)
- Loading branch information
1 parent
0d5ec0f
commit 141a86a
Showing
12 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,4 +140,8 @@ export function registerConsoleShortcuts(ctx: Vitest) { | |
} | ||
|
||
on() | ||
|
||
return function cleanup() { | ||
off() | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { getHelloWorld } from './example' | ||
|
||
test('getHello', async () => { | ||
expect(getHelloWorld()).toBe('Hello world') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getHelloWorld() { | ||
return 'Hello world' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { sum } from './math' | ||
|
||
test('sum', () => { | ||
expect(sum(1, 2)).toBe(3) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function sum(a: number, b: number) { | ||
return a + b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
// Patch stdin on the process so that we can fake it to seem like a real interactive terminal and pass the TTY checks | ||
process.stdin.isTTY = true | ||
process.stdin.setRawMode = () => process.stdin | ||
|
||
export default defineConfig({ | ||
test: { | ||
watch: false, | ||
reporters: 'verbose', | ||
teardownTimeout: 5_000, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@vitest/test-run", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest" | ||
}, | ||
"devDependencies": { | ||
"vite": "latest", | ||
"vitest": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expect, test } from 'vitest' | ||
import { runVitestCli } from '../../test-utils' | ||
|
||
test('run mode does not get stuck when TTY', async () => { | ||
const vitest = await runVitestCli('--root', 'fixtures') | ||
await vitest.isDone | ||
|
||
expect(vitest.stdout).toContain('✓ example.test.ts') | ||
expect(vitest.stdout).toContain('✓ math.test.ts') | ||
expect(vitest.stdout).toContain('2 passed') | ||
|
||
// Regression #3642 | ||
expect(vitest.stderr).not.toContain('close timed out') | ||
expect(vitest.stderr).toBe('') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
reporters: 'verbose', | ||
include: ['test/**/*.test.*'], | ||
chaiConfig: { | ||
truncateThreshold: 0, | ||
}, | ||
testTimeout: process.env.CI ? 30_000 : 10_000, | ||
}, | ||
}) |