Guide

Testing VitePress documentation examples

Keep the VitePress production build and the reader-facing examples as separate checks, and review how code groups and includes are treated.

Published
Updated
November 10, 2026
Reading time
14 min
Facts checked against
VitePress Markdown, CLI, getting started and site configuration documentation (November 9, 2026)
Outlined documentation pages with a lime pulse line running out of the stack
On this pageThe short answerStart with the page a reader seesFollow included content to its sourceBuild and preview separatelyRun supported examples in page contextMap the page to an executable journeyTriage the resultChecklist for a VitePress example testWhat this does not replaceThe sources we checkedFAQ

The short answer

Build the VitePress site and test its examples as separate checks. vitepress build builds the site for production; a successful build does not establish that commands or code shown in its pages run when a reader copies them. Review the rendered site and its links as well as the outcome of example tests.

DocsAlive reads a VitePress project's Markdown pages in plain Markdown mode. It does not detect VitePress, read .vitepress configuration, run the VitePress CLI, render the site or check links. It can run supported fenced examples, but it does not recognize ::: code-group as a group of alternatives: consecutive fences inside it are each planned independently. Inspect the plan, especially where the page presents mutually exclusive installation paths.

Start with the page a reader sees

VitePress authors write pages in Markdown. The Markdown guide describes fenced code blocks, presentation features, custom containers, code groups, imported snippets and Markdown inclusion. These features can make a page easier to follow, but they also make it important to distinguish the page source, the built page and the code actually exercised by a test.

A page can contain a short JavaScript example, a command to install a package and a result that the reader should expect. Each is a different promise. The code must match the API, the install command must be usable with the stated prerequisites, and the surrounding prose must tell a reader what to do next. A production build is valuable evidence that the site was built; it is not evidence that those promises were executed.

Start an inventory with the entry points readers use: a getting-started page, installation instructions, examples for common tasks and any repository README. Identify each page's source and its dependencies on other pages or files. The static-site guide covers the relationship between source and built site, while the README guide addresses another common entry point.

Fences and highlighting

A fenced block gives a snippet a boundary and can identify its language. VitePress also describes line highlighting for code blocks. Highlighting guides the reader's attention, but it is a presentation choice, not a runtime assertion. If a highlighted line calls an API, a separate check should establish whether that call is valid in the intended environment.

For a raw Markdown scan, the fence info string matters. DocsAlive takes the first word as the language. A plain js or python fence can therefore be planned according to that language. Review the report rather than inferring execution from the rendered color or a fence label. A passing status can reflect execution or syntax checking, depending on the block's treatment.

Keep complete runnable examples distinct from illustrative fragments. If a page intentionally shows only a part of a program, explain what surrounds it. If the page claims a snippet can be copied and run, test it with the dependencies and setup a reader is told to use. A working snippet is strongest evidence when it checks a meaningful result, not merely when it exits successfully.

Custom containers and code groups

The VitePress Markdown reference describes info, tip, warning, danger and details custom containers. They can have titles and contents, including a code block. Their presence changes how content is presented; the instructions inside still need the right prerequisites and an appropriate check. Inspect the built page to see whether a warning or details section communicates the intended context.

A Code Group uses ::: code-group around multiple fences. A fence can carry a label such as js [config.js] or ts [config.ts]. The labels let readers choose a presented example. VitePress also documents imported snippets using <<<, including imports inside code groups. A source file can therefore supply code that is not written directly as a fence in the page being edited.

The following is a fictional page excerpt. The package name illustrates the shape of installation choices; it is not a claim that a package is published. The JavaScript block is self-contained. The installation commands assume their respective package managers are already available.

# Start with the demo

```js
const greeting = 'Hello from the demo';
console.log(greeting);
```

Choose one installation method:

::: code-group

```sh [npm]
npm install acme-docs-demo
```

```sh [pnpm]
pnpm add acme-docs-demo
```

:::

A reader chooses one install method. Test each important choice from an equivalent clean starting environment, then test the later steps that depend on it. Running both commands in one environment is a different journey: the first can affect the second, and a result may not show whether either path works independently. Record which installer and prerequisite state each test used.

DocsAlive does not recognize the VitePress code-group container as an alternatives group. It plans the consecutive fences individually rather than selecting one and skipping the other as alt-variant. Review the plan before treating its result as coverage of the reader's choice. Arrange separate independent tests for the variants that matter. Compare this behavior with the recognized grouping described in the Docusaurus guide and MkDocs guide; do not assume a group syntax has the same treatment across frameworks.

Follow included content to its source

The VitePress Markdown reference describes importing code snippets with <<< and including Markdown with <!--@include: ...-->. Markdown inclusion can be nested and can select a line range. A path prefixed with @ uses the source root; the project root is the default source root unless srcDir is configured. These details help identify which file supplies content to the page a reader sees.

For an included passage, record both the page that presents it and the source file that supplies it. Check whether the surrounding page supplies the imports, setup and explanation required by the included material. A snippet reused in two contexts can work in one journey while the other omits an important prerequisite. A source-file test and a page review answer related but different questions.

A scan of raw page files does not by itself prove that an imported or included passage was expanded and executed as the built site presents it. Inspect the extracted findings, test the source or assembled content separately where needed, and inspect the built page. If the same source is reused, keep a route back to it in the issue so a maintainer fixes the actual authoring location.

Build and preview separately

The VitePress CLI reference says vitepress dev starts a development server using the designated root; in the current directory the dev command can be omitted. vitepress build builds the site for production. Its --base option sets the public base path. vitepress preview locally previews a production build. Use the settings and root appropriate to the actual site.

A successful build shows that the production build completed under that configuration. It does not show that the examples readers copy were executed, that every installation route works, or that a remote service returned the described response. A preview helps a person inspect the built site, including presentation and context, but it is not a substitute for executing examples or checking the links independently.

Keep build failures and example failures distinct in your records. A Markdown rendering issue may need a site configuration or source change; a failing command may need a corrected prerequisite or API call. A code sample can work while being hard to read in the rendered page, and a well-rendered sample can fail when copied. Both observations are useful, with different fixes and owners.

Run supported examples in page context

DocsAlive reads .md, .mdx and .markdown files under the docs directory: docs/ if present, otherwise the repository root, or the folder selected with --docs-dir. It falls back to plain Markdown mode for a VitePress project. It does not read .vitepress configuration or use the VitePress CLI to determine what appears on the site. Compare the files scanned with the site's actual page inventory.

The engine plans supported blocks in page order and runs a fresh container for each page. Earlier steps can provide state for later steps on the same page, which can match a sequential tutorial. A fresh page container also helps reveal a dependency that exists on a maintainer's machine but is absent from the instructions. It does not by itself test a journey that begins on one page and continues on another.

Supported languages include Python, JavaScript, shell, curl and HTTP examples; JSON and TOML are validated. Simple TypeScript annotations are stripped before execution, but other TypeScript-only syntax is not judged. JSX and TSX are not judged. Go, Rust, Java, Ruby and PHP are recognized but not executed. Credential examples are classified, not executed with real keys. Review the frameworks reference and the JavaScript, Python and TypeScript guides for the implications for individual pages.

Keep test-only setup visible. The CLI's --setup command runs at the start of each page container, and can install a dependency needed for the test. If that setup supplies something the page should teach, add or clarify the reader-facing prerequisite rather than silently relying on the harness. The CLI reference describes selection and reporting options.

A generic CI outline

Run these shell commands from the appropriate project root after the site dependencies and product CLI are available. The scan pattern is an illustration; adjust it to match the pages in the repository.

vitepress build
docsalive scan . --execute --include "docs/quickstart*" --out docs-test-report

The first result is the production build; the second is a report about supported extracted blocks. Inspect report.md and report.json in the output directory for skips, reasons and hints. Review the built page and check links separately. The GitLab CI guide describes placing a check in a job; the GitHub Actions guide covers a sibling CI workflow.

Run the checks on changes to pages and APIs, and repeat them periodically to catch drift in dependencies. A scheduled check has value only if someone reviews and routes the result. Keep an owner and a reproduction path for failures, including the source file and the setup used for the test.

Map the page to an executable journey

Before selecting a scan command, write down what a reader is expected to do in order. An installation page may first name a prerequisite, then offer a package-manager choice, then show an import and a small use of the installed package. The useful test is the path through those steps, including a meaningful result. Merely finding a fence on the page does not establish that every prerequisite or alternative was covered.

For each path, note the starting environment, the chosen commands, the expected outcome and the source location to fix if it fails. Keep the test environment clean enough to reveal missing setup. Within one path, preserve state so the import sees the installation and a later example sees earlier variables. For a second package-manager choice, reset the environment and repeat the journey. This makes it easier to tell whether the documented choice itself works.

The page excerpt above deliberately uses a fictional package. It illustrates how alternatives are authored, not a command to run against a real package registry. In a real repository, replace it with the package readers are meant to install and verify the package source and prerequisites. If the check uses a local build while the page tells readers to install a published package, record the difference and provide separate coverage for the published path where it matters.

Compare source scope with the site

VitePress configuration and inclusions can affect the pages a reader sees. The scan's file selection is based on the docs directory and supported file endings, not on reading .vitepress configuration. Compare the actual list of scanned files with the site's intended pages. A file that exists in the repository is not necessarily an important reader entry point, and a reader-visible passage may be authored in a different file from the page that presents it.

Use the report to confirm the extracted fences and their source locations. If an imported snippet or included Markdown passage is absent, identify its source and provide a separate test for the content as used. If it appears in several pages, check each context: a shared sample can rely on an import introduced on one page but missing on another. A single standalone test of the source is useful, but it does not establish that each page teaches the complete journey.

Presentation also deserves its own review. A warning container may provide an essential prerequisite, or a details container may conceal a step the reader needs. Check the built page to make sure the relationship between the text, the container and the example is understandable. Line highlighting can emphasize a change, but the unhighlighted lines still contribute to the runnable program and can break. Review the entire sample as well as the emphasized line.

Keep the result useful to a reviewer

A report should tell a reviewer what was executed, what was validated without execution and what was skipped. Keep the command, selected directory, setup, source location and actual error with the result. For an output mismatch, determine whether the difference changes the page's promise or reflects a variable field. Do not update the documented output simply to make the report green without understanding the difference.

If a page has both a plain supported fence and a code group, examine their treatment separately. The plain fence can be executed according to its language and plan. Each group fence is planned on its own, even though the rendered page presents choices. A combined run does not substitute for clean tests of both alternatives. Link the independent results to the page so a future editor understands the coverage decision.

When the site changes, rerun the production build and the example checks, then inspect the affected rendered page. A change to an included source can affect multiple pages, so review each important use. A change to a package API can affect examples even when the Markdown did not change. Periodic execution helps expose that drift, while the documentation testing checklist helps assign the follow-up.

Triage the result

Finding What to investigate Next action
Build fails Site source, configuration and build output Fix the build and rerun it
api-drift A supported example uses an API that no longer matches Reproduce against the intended package and update the example
stale-output The code runs but the shown result is old Confirm the intended output before changing it
missing-install-step A package is used without an install step on the page Review the hint and reader prerequisites
Both code-group fences are planned The group presents choices but the scan treats fences independently Test the alternatives separately in clean environments
Imported content is absent from findings The page uses content supplied elsewhere Trace and test the source or assembled content separately
unsupported-lang A recognized language such as Rust was skipped Use a native language check
needs-credentials The example requires credentials Record the gap and arrange a separate authorized check
runtime-error or timeout An error may need human review Preserve evidence and reproduce with the documented context

A finding is evidence to investigate, not an instruction to rewrite the page immediately. Compare the source, selected block, actual error and setup. A missing fixture or a dependency supplied only by a harness may explain the failure. After a change, rerun the affected checks and confirm that the displayed instructions still describe the path tested.

Checklist for a VitePress example test

Check Evidence to retain
Inventory authored pages and includes Page, source file and reader journey
Build the production site Command, configuration and build result
Inspect presentation and links Reviewed pages and separate link-check result
Identify code-group alternatives Each path and its independent test
Trace imported snippets and included Markdown Source location and separate test coverage
Check scanned file scope Directory, selected files and excluded content
Run supported fences in order Environment, setup, results and output comparison
Review skips and limitations Unsupported languages, credentials and syntax not judged
Triage and rerun changes Evidence, decision and verification result

What this does not replace

DocsAlive does not detect VitePress, read .vitepress configuration, run vitepress dev, vitepress build or vitepress preview, render the site or check links. It does not treat VitePress code groups as alternative tabs. Keep the build, preview, link checks, separate alternative-path tests and human review of the page.

It does not execute Go, Rust, Java, Ruby or PHP. TypeScript handling is limited to simple annotation stripping; other TypeScript-only syntax and JSX/TSX are not judged. Credentials are classified rather than used to execute examples with real keys. A pass can mean execution or a syntax check, so read the report's treatment before describing coverage. The Rust guide explains how to keep native Rust documentation tests, and the docs testing overview describes the wider workflow.

For a starting point, the free health check accepts a public repository you own or maintain; the team runs the engine on up to 40 of its docs pages and emails the real report within 2 business days; the checkout is deleted after the run. Pricing is Open source $0/month, Team $299/month, Growth $699/month, and Scale from $1,499/month.

See how it works and the guides for more ways to organize coverage.

The sources we checked

Source What it covers
VitePress Markdown Fences, highlighting, containers, code groups and inclusion
VitePress CLI Development, production build and preview commands
VitePress getting started Authoring and site setup
VitePress site configuration Site configuration and source directory

FAQ

Does vitepress build run code examples?

A successful command builds the production site. It is not evidence that examples were run; use a separate example check.

What does vitepress preview do?

It locally previews the production build. Inspect the result for presentation and context, and use separate checks for executable behavior and links.

Does the product detect VitePress?

No. A VitePress project falls back to plain Markdown mode, and the product does not read .vitepress configuration or run the VitePress CLI.

Are code-group choices treated as alternatives?

No. Consecutive fences in a VitePress code group are planned independently. Test each important reader choice separately from an equivalent clean state.

Are imported snippets automatically proven to run?

Do not assume that from a raw page scan. Inspect findings, trace the source and test the included or assembled content where needed.

What happens to TypeScript examples?

Simple type annotations are stripped before execution. Other TypeScript-only syntax is not judged, and JSX and TSX are not judged.

Can the product test Rust fences?

Rust is recognized but not executed. Keep native Rust tests as described in the Rust guide.

Should I test a page with credentials?

Record the gap and arrange an appropriate separate authorized check. The product classifies credential examples rather than executing them with real keys.

Keep reading
Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs Testing: How to Test the Code Samples in Your Docs

Why code examples in documentation break, the ways teams test them (doctest, docs-as-tests, CI runners) and how to run every sample on each release.

Two lenses held over the same documentation page, each bringing a different layer into focusComparison

Vale vs markdownlint: What Each Docs Linter Catches

Vale checks prose style; markdownlint checks Markdown structure. What each catches, sample configs, running both in CI and what neither one tests.

Blueprint of two documentation pages: one with a handwritten test script, one whose code blocks are framed and checkedComparison

Doc Detective vs DocsAlive: Testing the Code in Your Docs

Doc Detective is a free, open-source docs-as-tests framework; DocsAlive is a hosted docs CI for code examples. Features, price, setup and when to use each.

A machine blueprint above a ruled documentation page, with a caliper measuring between themComparison

Promptless Alternative: Promptless vs DocsAlive Compared

Promptless drafts docs updates from what you ship; DocsAlive runs the code examples you've published. Features, pricing, security and when to use each.

A long workbench of outlined testing instruments, each with a small lime light, beside a stack of documentation pagesGuide

Best Free Tools to Test Code Examples in Documentation

Free, open-source tools that run the code examples in your docs: rustdoc, Go examples, doctest, pytest plugins, Sphinx doctest, Doc Detective and byexample.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing SDK Docs Before Every Release: A Release-Gate Guide

Test SDK and client-library docs against the package you ship: build the wheel or npm tarball, install it clean, run every example, and gate the release in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test Quickstarts and Tutorials in Your Docs

Test the onboarding path a new reader follows: run quickstarts in a clean environment, in page order, sort real bugs from credentials and fragments, and wire it into CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test CLI Documentation: Commands, Flags and Output

Test the commands a CLI page promises: install in a clean container, run examples in order, compare flags with --help, check exit codes and output, and run it in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

How to Test API Reference Docs: Requests, Responses and SDKs

Test API reference pages against the contract they publish: methods, parameters, request and response examples, SDK snippets, status codes and OpenAPI samples.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for API-first companies

Keep API quickstarts, SDK snippets and curl examples working across releases.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs testing for CLI and developer-tool vendors

Test developer-tool install paths, package managers and command examples across releases.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing README Code Examples: Install, Usage and CI

Keep README install commands and usage examples working with clean environments, output checks and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Notebooks and Executable Docs: Cells, Kernels and Output

Test notebooks in fresh kernels, check meaningful output and manage dependencies, data and drift in CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Docs in GitHub Actions: Pull Requests and Scheduled Checks

Run documentation example checks in GitHub Actions with practical guidance on schedules, path filters, caching, secrets and reports.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Code Examples in MkDocs, Docusaurus and Sphinx Sites

Find and test documentation examples in Markdown, MDX and reStructuredText, alongside site builds and link checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Python Docs Testing: Doctest, Pytest and Markdown

Test Python documentation with doctest, pytest, Markdown example execution and isolated environments.

Outlined documentation pages with a lime pulse line running out of the stackGuide

JavaScript Docs Testing: Node, TypeScript and Modules

Test Node and TypeScript documentation examples across module formats, package versions and type checks.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Go documentation examples

Test Go example functions and Markdown snippets against the intended module versions in clean environments.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Sphinx Docs Testing: doctest, code-block and MyST

Test Sphinx documentation examples: what the doctest and linkcheck builders prove, code-block and literalinclude, MyST fences, and what a Markdown scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

ReadMe Docs Testing: CLI, OpenAPI and Code Examples

Test ReadMe documentation examples: docs-as-code and bi-directional sync, what lint and oas:validate prove, Tabs variants and runnable code.

Outlined documentation pages with a lime pulse line running out of the stackGuide

TypeScript Docs Testing: tsc --noEmit and Runtime

Test TypeScript documentation examples: type-check snippets with tsc --noEmit in a consumer project, then run them, and what each check proves.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docusaurus Docs Testing: Code Blocks, Tabs and MDX

Test Docusaurus documentation examples: builds vs runnable code, code block metadata, Tabs install variants, MDX pages and clean-container runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Mintlify Docs Testing: CodeGroup, Tabs and the CLI

Test Mintlify documentation examples: docs.json, MDX pages, CodeGroup and Tabs variants, what mint broken-links and mint validate prove, and clean runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

MkDocs Docs Testing: Code Examples, Tabs and Snippets

Test MkDocs documentation examples: strict builds, Material tabs, Snippets includes, mkdocstrings pages and clean-container runs.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Installation Instructions: pip, npm and Containers

Test documented install steps in clean environments: pip and extras, venv, npm install vs npm ci, containers and the first import.

Outlined documentation pages with a lime pulse line running out of the stackGuide

AI SDK Docs Testing: LLM Examples, Keys and Drift

Test AI and LLM SDK documentation examples: requests, responses, streaming, tool calls, credentials, model retirements and CI.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing migration guides and changelog examples

Test before and after examples against the right releases and make migration documentation part of the release gate.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Docs Testing Checklist: Code Examples Before Release

A practical pre-release checklist for testing documentation examples, reviewing gaps and verifying published packages.

Outlined documentation pages with a lime pulse line running out of the stackGuide

The Cost of Broken Code Examples in Documentation

Understand how broken documentation examples create friction in developer adoption and support, and how to reduce it.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Rust documentation examples

Test Rust rustdoc examples and cargo documentation tests, and keep native Rust checks because compiled Rust fences are recognized but not executed.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing docs in GitLab CI

Run documentation example checks in GitLab CI jobs, keep site builds separate from execution, and review what a scan covers and skips.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing JSON, TOML and YAML examples in docs

Test JSON, TOML and YAML config examples in documentation: parse, schema and tool checks, honest fence labels, fragments, CI jobs and what a scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing Java documentation examples

Test Java examples in READMEs, SDK docs and Javadoc: the source launcher, javac, JShell scripts, assertions, @snippet files, CI and what a scan covers.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing PHP documentation examples

Test PHP examples in docs: php -l lint, clean-directory runs, assertions with zend.assertions, Composer scratch projects, PHPUnit, CI and scan coverage.

Outlined documentation pages with a lime pulse line running out of the stackGuide

Testing docs examples that need API keys

Test credential-gated docs examples: honest placeholders, offline stubs and fixtures, live sandbox jobs, CI secrets and fork rules, and how a scan classifies them.

A machine blueprint above a ruled documentation page, with a caliper measuring between themGuide

Documentation Drift: How to Detect It Before Users Do

What documentation drift is, why code examples drift first, and practical ways to detect it: ownership, release checks, link and execution tests.

See which of your code samples still run.

Send us a public repository. Our team runs DocsAlive on its docs and emails you the real report within 2 business days. Free, no signup.