Skip to content

Commit 0da12aa

Browse files
authored
fix(types): allow changed in configuration options (#10651)
1 parent 5b86421 commit 0da12aa

6 files changed

Lines changed: 36 additions & 21 deletions

File tree

docs/.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ export default ({ mode }: { mode: string }) => {
583583
text: 'disableConsoleIntercept',
584584
link: '/config/disableconsoleintercept',
585585
},
586+
{
587+
text: 'changed',
588+
link: '/config/changed',
589+
},
586590
{
587591
text: 'experimental',
588592
link: '/config/experimental',

docs/.vitepress/scripts/cli-generator.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const nonNullable = <T>(value: T): value is NonNullable<T> => value !== null &&
1111

1212
const skipCli = new Set([
1313
'mergeReports',
14-
'changed',
1514
'shard',
1615
])
1716

docs/config/changed.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: changed | Config
3+
outline: deep
4+
---
5+
6+
### changed <CRoot />
7+
8+
- **Type:** `boolean | string`
9+
- **Default:** `false`
10+
- **CLI:** `--changed`, `--changed=HEAD~1`
11+
12+
Run tests only against changed files. If no value is provided, it will run tests against uncommitted changes (including staged and unstaged).
13+
14+
To run tests against changes made in the last commit, you can use `--changed HEAD~1`. You can also pass commit hash (e.g. `--changed 09a9920`) or branch name (e.g. `--changed origin/develop`).
15+
16+
When used with code coverage the report will contain only the files that were related to the changes.
17+
18+
If paired with the [`forceRerunTriggers`](/config/forcereruntriggers) config option it will run the whole test suite if at least one of the files listed in the `forceRerunTriggers` list changes. By default, changes to the Vitest config file and `package.json` will always rerun the whole suite.

docs/guide/cli-generated.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,13 @@ Allow tests and suites that are marked as only (default: `!process.env.CI`)
541541

542542
Ignore any unhandled errors that occur
543543

544+
### changed
545+
546+
- **CLI:** `--changed [since]`
547+
- **Config:** [changed](/config/changed)
548+
549+
Run tests that are affected by the changed files (default: `false`)
550+
544551
### sequence.shuffle.files
545552

546553
- **CLI:** `--sequence.shuffle.files`

docs/guide/cli.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,6 @@ vitest --api=false
189189

190190
<!--@include: ./cli-generated.md-->
191191

192-
### changed
193-
194-
- **Type:** `boolean | string`
195-
- **Default:** false
196-
197-
Run tests only against changed files. If no value is provided, it will run tests against uncommitted changes (including staged and unstaged).
198-
199-
To run tests against changes made in the last commit, you can use `--changed HEAD~1`. You can also pass commit hash (e.g. `--changed 09a9920`) or branch name (e.g. `--changed origin/develop`).
200-
201-
When used with code coverage the report will contain only the files that were related to the changes.
202-
203-
If paired with the [`forceRerunTriggers`](/config/forcereruntriggers) config option it will run the whole test suite if at least one of the files listed in the `forceRerunTriggers` list changes. By default, changes to the Vitest config file and `package.json` will always rerun the whole suite.
204-
205192
### shard
206193

207194
- **Type:** `string`

packages/vitest/src/node/types/config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,13 @@ export interface InlineConfig {
985985
* @default true
986986
*/
987987
strictTags?: boolean
988+
989+
/**
990+
* Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
991+
* Requires initialized git repository
992+
* @default false
993+
*/
994+
changed?: boolean | string
988995
}
989996

990997
export interface TypecheckConfig {
@@ -1073,13 +1080,6 @@ export interface UserConfig extends InlineConfig {
10731080
*/
10741081
mode?: string
10751082

1076-
/**
1077-
* Runs tests that are affected by the changes in the repository, or between specified branch or commit hash
1078-
* Requires initialized git repository
1079-
* @default false
1080-
*/
1081-
changed?: boolean | string
1082-
10831083
/**
10841084
* Test suite shard to execute in a format of <index>/<count>.
10851085
* Will divide tests into a `count` numbers, and run only the `indexed` part.

0 commit comments

Comments
 (0)