Skip to content

Commit fce23be

Browse files
authored
Merge branch 'main' into docs-document-auto-cleanup-behavior
2 parents 48e16e2 + 5375780 commit fce23be

63 files changed

Lines changed: 2087 additions & 271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/issue-labeled.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@ name: Issue Labeled
33
on:
44
issues:
55
types: [labeled]
6-
pull_request:
6+
pull_request_target:
77
types: [labeled]
88

9+
# for actions-cool/issues-helper to update issues
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
914
jobs:
1015
reply-labeled:
1116
runs-on: ubuntu-latest
12-
permissions:
13-
issues: write # for actions-cool/issues-helper to update issues
1417
steps:
1518
- name: needs reproduction
1619
if: github.event.label.name == 'needs reproduction'
@@ -21,19 +24,37 @@ jobs:
2124
issue-number: ${{ github.event.issue.number }}
2225
body: |
2326
Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://vitest.new) (you can also use [examples](https://github.com/vitest-dev/vitest/tree/main/examples)). Issues marked with `needs reproduction` will be closed if they have no activity within 3 days.
24-
- name: maybe automated
25-
if: github.event.label.name == 'maybe automated'
27+
- name: maybe automated (issues)
28+
if: github.event.label.name == 'maybe automated' && github.event_name == 'issues'
2629
uses: actions-cool/issues-helper@71b62d7da76e59ff7b193904feb6e77d4dbb2777 # v3.7.6
2730
with:
2831
actions: create-comment
2932
token: ${{ secrets.GITHUB_TOKEN }}
3033
issue-number: ${{ github.event.issue.number }}
3134
body: |
32-
Hello @${{ github.event.issue.user.login }}. Your content has been labeled `maybe automated` because it appears to have been fully generated by AI with no human involvement. It will be **closed automatically in 3 days** unless a real person responds.
35+
Hello @${{ github.event.issue.user.login }}. Your issue has been labeled `maybe automated` because it appears to have been fully generated by AI with no human involvement. It will be **closed automatically in 3 days** unless a real person responds.
36+
37+
If you're a real person behind this contribution, please:
38+
- Confirm you've personally reviewed and stand behind its content
39+
- Make sure it follows our [contribution guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md) and uses the correct [GitHub template](https://github.com/vitest-dev/vitest/blob/main/.github/ISSUE_TEMPLATE/bug_report.yml)
40+
- Disclose any AI tools you used (e.g. Claude, Copilot, Codex)
41+
42+
If you believe this was flagged by mistake, leave a comment.
43+
44+
*These measures help us reduce maintenance burden and keep the team's work efficient. See our [AI contributions policy](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md#ai-contributions) for more context.*
45+
- name: maybe automated (pr)
46+
if: github.event.label.name == 'maybe automated' && github.event_name == 'pull_request_target'
47+
uses: actions-cool/issues-helper@71b62d7da76e59ff7b193904feb6e77d4dbb2777 # v3.7.6
48+
with:
49+
actions: create-comment
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
issue-number: ${{ github.event.pull_request.number }}
52+
body: |
53+
Hello @${{ github.event.pull_request.user.login }}. Your PR has been labeled `maybe automated` because it appears to have been fully generated by AI with no human involvement. It will be **closed automatically in 3 days** unless a real person responds.
3354
3455
If you're a real person behind this contribution, please:
3556
- Confirm you've personally reviewed and stand behind its content
36-
- Make sure it follows our [contribution guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md) and uses the correct GitHub template ([PR](https://github.com/vitest-dev/vitest/blob/main/.github/PULL_REQUEST_TEMPLATE.md), [issue](https://github.com/vitest-dev/vitest/blob/main/.github/ISSUE_TEMPLATE/bug_report.yml))
57+
- Make sure it follows our [contribution guidelines](https://github.com/vitest-dev/vitest/blob/main/CONTRIBUTING.md) and uses the correct [GitHub template](https://github.com/vitest-dev/vitest/blob/main/.github/PULL_REQUEST_TEMPLATE.md)
3758
- Disclose any AI tools you used (e.g. Claude, Copilot, Codex)
3859
3960
If you believe this was flagged by mistake, leave a comment.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Label Automated PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
label:
13+
runs-on: ubuntu-latest
14+
if: contains(github.event.pull_request.body, '<!-- VITEST_AUTOMATED_PR -->')
15+
steps:
16+
- name: maybe automated
17+
uses: actions-cool/issues-helper@71b62d7da76e59ff7b193904feb6e77d4dbb2777 # v3.7.6
18+
with:
19+
actions: add-labels
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
issue-number: ${{ github.event.pull_request.number }}
22+
labels: maybe automated

AGENTS.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,13 @@ If you need to typecheck tests, run `pnpm typecheck` from the root of the worksp
158158
- Check existing issues and documentation
159159
- Review CONTRIBUTING.md for detailed guidelines
160160
- Follow patterns in existing code
161+
162+
## PR Descriptions
163+
164+
When creating a pull request, you MUST include the following HTML comment at the bottom of the PR description:
165+
166+
```
167+
<!-- VITEST_AUTOMATED_PR -->
168+
```
169+
170+
This allows maintainers to identify AI-assisted PRs for triage. PRs containing this marker will be automatically labeled `maybe automated` and will be closed in 3 days unless a real person confirms ownership.

CLAUDE.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
# CLAUDE.md
2-
3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4-
5-
## Codebase Overview
6-
7-
Vitest is a next-generation testing framework powered by Vite. This is a monorepo using pnpm workspaces.
8-
9-
## Essential references
10-
11-
- Agent-specific guide: See [AGENTS.md](AGENTS.md)
1+
@AGENTS.md

docs/api/browser/context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ utils.configurePrettyDOM({
292292
- **`maxLength`** - Maximum length of the output string (default: `7000`)
293293
- **`filterNode`** - A CSS selector string or function to filter out nodes from the output. When a string is provided, elements matching the selector will be excluded. When a function is provided, it should return `false` to exclude a node.
294294
- **`highlight`** - Enable syntax highlighting (default: `true`)
295-
- And other options from [`pretty-format`](https://npmx.dev/package/@vitest/pretty-format)
295+
- And other options from [`@vitest/pretty-format`](https://npmx.dev/package/@vitest/pretty-format)
296296
297297
#### Filtering with CSS Selectors <Version>4.1.0</Version> {#filtering-with-css-selectors}
298298

docs/config/coverage.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ You can also pass custom coverage reporters. See [Guide - Custom Coverage Report
133133

134134
You can check your coverage report in Vitest UI: check [Vitest UI Coverage](/guide/coverage#vitest-ui) for more details.
135135

136+
::: tip AI coding agents
137+
When Vitest detects it is running inside an AI coding agent, it automatically adds the `text-summary` reporter and sets `skipFull: true` on the `text` reporter to reduce output and minimize token usage.
138+
:::
139+
136140
## coverage.reportOnFailure {#coverage-reportonfailure}
137141

138142
- **Type:** `boolean`

docs/config/diff.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ outline: deep
1010

1111
`DiffOptions` object or a path to a module which exports `DiffOptions`. Useful if you want to customize diff display.
1212

13+
Vitest diff rendering uses [`@vitest/pretty-format`](https://npmx.dev/package/@vitest/pretty-format) under the hood and a part of `DiffOptions` is forwarded to the pretty-format configuration, while the rest affects diff rendering itself.
14+
1315
For example, as a config object:
1416

1517
```ts

docs/config/experimental.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,3 +479,36 @@ export default {
479479
If module runner is disabled, Vitest uses a native [Node.js module loader](https://nodejs.org/api/module.html#customization-hooks) to transform files to support `import.meta.vitest`, `vi.mock` and `vi.hoisted`.
480480

481481
If you don't use these features, you can disable this to improve performance.
482+
483+
## experimental.preParse <Version type="experimental">4.1.3</Version> {#experimental-preparse}
484+
485+
- **Type:** `boolean`
486+
- **Default:** `false`
487+
488+
Parses test specifications before running them. This applies the [`.only`](/api/test#test-only) modifier, the [`-t`](/config/testnamepattern) test name pattern, [`--tags-filter`](/guide/test-tags#syntax), [test lines](/api/advanced/test-specification#testlines), and [test IDs](/api/advanced/test-specification#testids) across all files without executing them. For example, if only a single test is marked with `.only`, Vitest will skip all other tests in all files.
489+
490+
::: tip
491+
This option is recommended when using [`.only`](/api/test#test-only), the [`-t`](/config/testnamepattern) flag, or [`--tags-filter`](/guide/test-tags#syntax).
492+
493+
Enabling it unconditionally may slow down your test runs due to the additional parsing step.
494+
:::
495+
496+
::: warning
497+
Pre-parsing uses static analysis (AST parsing) instead of executing your test files. This means that test names, tags, and modifiers (`.only`, `.skip`, `.todo`) must be statically analyzable. Dynamic test names (e.g., names stored in variables or returned from function calls) and non-literal tags will not be resolved correctly.
498+
499+
```ts
500+
// ✅ works — static string literal
501+
test('adds numbers', () => {})
502+
503+
// ✅ works — static tags
504+
test('my test', { tags: ['unit'] }, () => {})
505+
506+
// ❌ won't match correctly — dynamic name
507+
const name = getName()
508+
test(name, () => {})
509+
510+
// ❌ won't match correctly — dynamic tags
511+
const tags = getTags()
512+
test('my test', { tags }, () => {})
513+
```
514+
:::

docs/config/snapshotformat.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@ outline: deep
55

66
# snapshotFormat <CRoot />
77

8-
- **Type:** `PrettyFormatOptions`
8+
- **Type:** `Omit<PrettyFormatOptions, 'plugins' | 'compareKeys'> & { compareKeys?: null | undefined }`
99

10-
Format options for snapshot testing. These options are passed down to our fork of [`pretty-format`](https://npmx.dev/package/pretty-format). In addition to the `pretty-format` options we support `printShadowRoot: boolean`.
10+
Format options for snapshot testing. These options configure the snapshot-specific formatting layer built on top of [`@vitest/pretty-format`](https://npmx.dev/package/@vitest/pretty-format).
11+
12+
For the full option surface of `PrettyFormatOptions`, see [`@vitest/pretty-format`](https://npmx.dev/package/@vitest/pretty-format). This page focuses on the Vitest snapshot-specific defaults and constraints.
13+
14+
Vitest snapshots already apply these defaults before your `snapshotFormat` overrides:
15+
16+
- `printBasicPrototype: false`
17+
- `escapeString: false`
18+
- `escapeRegex: true`
19+
- `printFunctionName: false`
20+
21+
Vitest also supports formatter options such as `printShadowRoot` and `maxOutputLength` in `snapshotFormat`.
22+
23+
`printShadowRoot` controls whether shadow-root contents are included in DOM snapshots.
24+
25+
`maxOutputLength` is an approximate per-depth output budget, not a hard cap on the final rendered string.
26+
27+
By default, snapshot keys are sorted using the formatter's default behavior. Set `compareKeys` to `null` to disable key sorting. Custom compare functions are not supported in `snapshotFormat`.
1128

1229
::: tip
13-
Beware that `plugins` field on this object will be ignored.
30+
Beware that `plugins` on this object will be ignored.
1431

15-
If you need to extend snapshot serializer via pretty-format plugins, please, use [`expect.addSnapshotSerializer`](/api/expect#expect-addsnapshotserializer) API or [snapshotSerializers](/config/snapshotserializers) option.
32+
If you need to extend snapshot serialization via pretty-format plugins, use [`expect.addSnapshotSerializer`](/api/expect#expect-addsnapshotserializer) or [`snapshotSerializers`](/config/snapshotserializers) instead.
1633
:::

docs/guide/cli-generated.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,10 @@ Controls whether Vitest will use Node.js Loader API to process in-source or mock
963963
- **Config:** [experimental.vcsProvider](/config/experimental#experimental-vcsprovider)
964964

965965
Custom provider for detecting changed files. (default: `git`)
966+
967+
### experimental.preParse
968+
969+
- **CLI:** `--experimental.preParse`
970+
- **Config:** [experimental.preParse](/config/experimental#experimental-preparse)
971+
972+
Parse test specifications before running them. This will apply `.only` flag and test name pattern across all files without running them. (default: `false`)

0 commit comments

Comments
 (0)