Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

- name: Set node version to 20
- name: Set node version to 24
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24
registry-url: https://registry.npmjs.org/
cache: pnpm

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0

- name: Set node version to 20
- name: Set node version to 24
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24
registry-url: https://registry.npmjs.org/
# disable cache to avoid cache poisoning
package-manager-cache: false
Expand Down
197 changes: 141 additions & 56 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,30 +818,19 @@ export default ({ mode }: { mode: string }) => {
},
],
},
// Authoring — how to express a test in code: constructing it,
// asserting, mocking dependencies, attaching metadata. The page is
// about *test content*, not the runner. Discriminator: "How do I
// write X in a test?" If yes, it belongs here. Mocking sub-pages
// live nested because they're a multi-page subtopic.
{
text: 'Guides',
text: 'Authoring',
collapsed: false,
items: [
{
text: 'CLI',
link: '/guide/cli',
},
{
text: 'Test Filtering',
link: '/guide/filtering',
},
{
text: 'Test Tags',
link: '/guide/test-tags',
},
{
text: 'Test Context',
link: '/guide/test-context',
},
{
text: 'Test Environment',
link: '/guide/environment',
},
{
text: 'Test Run Lifecycle',
link: '/guide/lifecycle',
Expand Down Expand Up @@ -890,45 +879,85 @@ export default ({ mode }: { mode: string }) => {
],
},
{
text: 'Parallelism',
link: '/guide/parallelism',
},
{
text: 'Test Projects',
link: '/guide/projects',
text: 'Test Tags',
link: '/guide/test-tags',
},
{
text: 'Reporters',
link: '/guide/reporters',
text: 'Test Annotations',
link: '/guide/test-annotations',
},
{
text: 'Coverage',
link: '/guide/coverage',
text: 'Extending Matchers',
link: '/guide/extending-matchers',
},
{
text: 'Testing Types',
link: '/guide/testing-types',
},
{
text: 'Vitest UI',
link: '/guide/ui',
},
{
text: 'In-Source Testing',
link: '/guide/in-source',
},
],
},
// Workflow — how to invoke, select, and orchestrate test runs
// across files/projects/processes. The page is about the *runner
// and tooling around it*, not what's inside a test. Discriminator:
// "How do I run / filter / parallelize / integrate Vitest?" If a
// page is about the runtime environment of the tests themselves
// (jsdom, node), it still belongs here — that's a workflow choice.
{
text: 'Workflow',
collapsed: false,
items: [
{
text: 'Test Annotations',
link: '/guide/test-annotations',
text: 'CLI',
link: '/guide/cli',
},
{
text: 'Extending Matchers',
link: '/guide/extending-matchers',
text: 'Test Filtering',
link: '/guide/filtering',
},
{
text: 'Test Projects',
link: '/guide/projects',
},
{
text: 'Test Environment',
link: '/guide/environment',
},
{
text: 'Parallelism',
link: '/guide/parallelism',
},
{
text: 'Reporters',
link: '/guide/reporters',
},
{
text: 'Vitest UI',
link: '/guide/ui',
},
{
text: 'IDE Integration',
link: '/guide/ide',
},
],
},
// Quality & Debugging — how to verify the test run is healthy and
// diagnose it when it isn't. Coverage, perf, leak detection, error
// triage, observability. Discriminator: "Is my suite good?" or
// "Why did this fail / leak / slow down?" If a page primarily
// measures or fixes the suite (rather than authoring or running
// it), put it here.
{
text: 'Quality & Debugging',
collapsed: false,
items: [
{
text: 'Coverage',
link: '/guide/coverage',
},
{
text: 'Debugging',
link: '/guide/debugging',
Expand All @@ -937,25 +966,6 @@ export default ({ mode }: { mode: string }) => {
text: 'Common Errors',
link: '/guide/common-errors',
},
{
text: 'Migration Guide',
link: '/guide/migration',
collapsed: false,
items: [
{
text: 'Migrating to Vitest 4.0',
link: '/guide/migration#vitest-4',
},
{
text: 'Migrating from Jest',
link: '/guide/migration#jest',
},
{
text: 'Migrating from Mocha + Chai + Sinon',
link: '/guide/migration#mocha-chai-sinon',
},
],
},
{
text: 'Performance',
collapsed: false,
Expand All @@ -976,6 +986,62 @@ export default ({ mode }: { mode: string }) => {
},
],
},
// Recipes — end-to-end patterns that solve a concrete problem by
// combining multiple features. Each entry is titled by the problem
// ("Database Transaction per Test"), not the feature. Add a recipe
// when a single feature page would over-explain, when the value
// comes from composition, or when users would search by intent
// rather than by API name.
{
text: 'Recipes',
collapsed: false,
items: [
{
text: 'Database Transaction per Test',
link: '/guide/recipes/db-transaction',
},
{
text: 'Cancelling Long-Running Operations Gracefully',
link: '/guide/recipes/cancellable',
},
{
text: 'Waiting for Async Conditions',
link: '/guide/recipes/wait-for',
},
{
text: 'Type Narrowing in Tests',
link: '/guide/recipes/type-narrowing',
},
{
text: 'Custom Assertion Helpers',
link: '/guide/recipes/custom-assertions',
},
{
text: 'Watching Non-Imported Files',
link: '/guide/recipes/watch-templates',
},
{
text: 'Extending Browser Locators',
link: '/guide/recipes/browser-locators',
},
{
text: 'Schema-Driven Assertions',
link: '/guide/recipes/schema-matching',
},
{
text: 'Auto-Cleanup with `using`',
link: '/guide/recipes/explicit-resources',
},
{
text: 'Per-File Isolation Settings',
link: '/guide/recipes/disable-isolation',
},
{
text: 'Parallel and Sequential Test Files',
link: '/guide/recipes/parallel-sequential',
},
],
},
{
text: 'Advanced',
collapsed: false,
Expand All @@ -998,12 +1064,31 @@ export default ({ mode }: { mode: string }) => {
},
],
},
// Migration — one-time transitional content: cross-version
// upgrades and porting from other test runners (Jest, Mocha).
// Sits near the bottom because it's not daily-use and would push
// active-use guides further from the user's first scroll.
{
text: 'Migration',
link: '/guide/migration',
collapsed: false,
items: [
{
text: 'Recipes',
link: '/guide/recipes',
text: 'Migrating to Vitest 4.0',
link: '/guide/migration#vitest-4',
},
{
text: 'Migrating from Jest',
link: '/guide/migration#jest',
},
{
text: 'Migrating from Mocha + Chai + Sinon',
link: '/guide/migration#mocha-chai-sinon',
},
],
},
{
items: [
{
text: 'Comparisons',
link: '/guide/comparisons',
Expand Down
2 changes: 1 addition & 1 deletion docs/api/vi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ function resetConfig(): void

If [`vi.setConfig`](#vi-setconfig) was called before, this will reset config to the original state.

### vi.defineHelper <Version>4.1.0</Version> {#vi-defineHelper}
### vi.defineHelper <Version>4.1.0</Version> {#vi-definehelper}

```ts
function defineHelper<F extends (...args: any) => any>(fn: F): F
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/vitest-3-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export default defineConfig({
test: {
watchTriggerPatterns: [
{
pattern: /^src\/templates\/(.*)\.(ts|html|txt)$/,
pattern: /src\/templates\/(.*)\.(ts|html|txt)$/,
testsToRun: (file, match) => {
return `api/tests/mailers/${match[2]}.test.ts`
},
Expand Down
2 changes: 1 addition & 1 deletion docs/config/watchtriggerpatterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default defineConfig({
test: {
watchTriggerPatterns: [
{
pattern: /^src\/(mailers|templates)\/(.*)\.(ts|html|txt)$/,
pattern: /src\/(mailers|templates)\/(.*)\.(ts|html|txt)$/,
testsToRun: (id, match) => {
// relative to the root value
return `./api/tests/mailers/${match[2]}.test.ts`
Expand Down
6 changes: 5 additions & 1 deletion docs/guide/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ When debugging tests you might want to use following options:

## VS Code

The [official VS Code](https://vitest.dev/vscode) extension supports debugging tests via "Debug Tests" button. However Vitest also exposes tools to define a custom configuration.

Quick way to debug tests in VS Code is via `JavaScript Debug Terminal`. Open a new `JavaScript Debug Terminal` and run `npm run test` or `vitest` directly. *this works with any code run in Node, so will work with most JS testing frameworks*

![image](https://user-images.githubusercontent.com/5594348/212169143-72bf39ce-f763-48f5-822a-0c8b2e6a8484.png)
Expand Down Expand Up @@ -44,7 +46,9 @@ Then in the debug tab, ensure 'Debug Current Test File' is selected. You can the

### Browser mode

To debug [Vitest Browser Mode](/guide/browser/index.md), pass `--inspect` or `--inspect-brk` in CLI or define it in your Vitest configuration:
The simplest way to debug browser tests is to use the [official VS Code](https://vitest.dev/vscode) extension.

However you can also pass `--inspect` or `--inspect-brk` in CLI or define it in your Vitest configuration:

::: code-group
```bash [CLI]
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/improving-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24

- name: Install pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 24

- name: Install pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export default defineConfig({
```
:::

See [Recipes](/guide/recipes) for more examples.
See [Per-File Isolation Settings](/guide/recipes/disable-isolation) and [Parallel and Sequential Test Files](/guide/recipes/parallel-sequential) for more examples.

### Reporter Updates

Expand Down
Loading
Loading