new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Vitest · API reference · all subjects

out of scope

11 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Recent wasm-bindgen bundler avoids cyclic imports

The recent version of the wasm-bindgen bundler output does not use cyclic imports between wasm and js modules.

Externalization requirement for non-cyclic wasm-bindgen setup

For the non-cyclic wasm-bindgen version to work, both index_bg.js and index_bg.wasm need to be externalized to prevent a dual package hazard on index_bg.js that would make it non-functional.

Building Vitest docs locally

Run `pnpm docs` from the repo root to start a local dev server for the VitePress site in `docs/`.

Building Vitest docs for production

Run `pnpm docs:build` from the repo root. This command sets required environment variables and regenerates the CLI table. The built workspace packages must be available first, so run `pnpm build` at the repo root before building docs.

Type-checking code samples in docs

Code blocks tagged with `ts twoslash` are type-checked during `pnpm docs:build` only. The dev server skips twoslash and will not catch broken samples. Intentionally failing samples need `// @errors: <code>` comment. Use `// ---cut---` and `// @filename:` to hide setup lines. Changing public types in `packages/` can break twoslash samples.

Dead links in docs cause build failure

Dead internal links fail the build. Every CLI option gets a generated link to `/config/<option>`, so a new option needs a matching `docs/config/<option>.md` page or an entry in `skipConfig` in `docs/.vitepress/scripts/cli-generator.ts`.

Adding new documentation pages

New docs pages are not auto-discovered. Add a sidebar entry in `docs/.vitepress/config.ts`. The `/config`, `/guide`, and `/api` sidebars are hand-maintained arrays.

Marking API versions in docs

Mark the version an API appeared in with `<Version>X.Y.Z</Version>` in the heading, with an explicit `{#anchor}` following it. The component renders the trailing `+` itself. Experimental APIs use `<Version type="experimental">X.Y.Z</Version>` with `<Experimental />`. Deprecated APIs use `<Deprecated />`.

Config pages frontmatter and structure

Config pages use frontmatter `title: <name> | Config`, `outline: deep`, and a `- **Type:** / - **Default:** / - **CLI:**` list.

Generated file: docs/guide/cli-generated.md

The file `docs/guide/cli-generated.md` is generated from `packages/vitest/src/node/cli/cli-config.ts`. Regenerate it with `pnpm -C docs run cli-table` and commit the result. Never edit this file by hand.

Generated file: docs/.vitepress/contributor-names.json

The file `docs/.vitepress/contributor-names.json` is generated by running `pnpm docs:contributors`. Never edit this file by hand.

Give your agent this brain