Skip to content

Commit 6358f21

Browse files
kentonvhi-ogawasheremet-va
authored
fix: default to run mode when stdin is not a TTY (#7673)
Co-authored-by: Hiroshi Ogawa <[email protected]> Co-authored-by: Vladimir <[email protected]>
1 parent 5ba0d91 commit 6358f21

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

docs/config/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,15 @@ Update snapshot files. This will update all changed snapshots and delete obsolet
686686
### watch<NonProjectOption />
687687

688688
- **Type:** `boolean`
689-
- **Default:** `!process.env.CI`
689+
- **Default:** `!process.env.CI && process.stdin.isTTY`
690690
- **CLI:** `-w`, `--watch`, `--watch=false`
691691

692692
Enable watch mode
693693

694+
In interactive environments, this is the default, unless `--run` is specified explicitly.
695+
696+
In CI, or when run from a non-interactive shell, "watch" mode is not the default, but can be enabled explicitly with this flag.
697+
694698
### root
695699

696700
- **Type:** `string`

docs/guide/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ outline: deep
99

1010
### `vitest`
1111

12-
Start Vitest in the current directory. Will enter the watch mode in development environment and run mode in CI automatically.
12+
Start Vitest in the current directory. Will enter the watch mode in development environment and run mode in CI (or non-interactive terminal) automatically.
1313

1414
You can pass an additional argument as the filter of the test files to run. For example:
1515

@@ -50,7 +50,7 @@ Perform a single run without watch mode.
5050

5151
### `vitest watch`
5252

53-
Run all test suites but watch for changes and rerun tests when they change. Same as calling `vitest` without an argument. Will fallback to `vitest run` in CI.
53+
Run all test suites but watch for changes and rerun tests when they change. Same as calling `vitest` without an argument. Will fallback to `vitest run` in CI or when stdin is not a TTY (non-interactive environment).
5454

5555
### `vitest dev`
5656

packages/vitest/src/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const configDefaults: Readonly<{
131131
}> = Object.freeze({
132132
allowOnly: !isCI,
133133
isolate: true,
134-
watch: !isCI,
134+
watch: !isCI && process.stdin.isTTY,
135135
globals: false,
136136
environment: 'node' as const,
137137
pool: 'forks' as const,

0 commit comments

Comments
 (0)