Skip to content

Astro docs site

The Astro formatter turns your test output into a full Starlight documentation site. Run your tests, point the formatter at the results, and you get a browsable site with sidebar navigation, status badges, Mermaid diagrams, and search. Deploy it anywhere you’d deploy a static site.

Scaffold a new docs site and install dependencies:

Terminal window
npx executable-stories init-astro my-docs
cd my-docs
pnpm install

This creates a ready-to-run Starlight project with the right directory structure and Mermaid support pre-configured. The generated stories go into src/content/docs/stories/ and Starlight auto-generates the sidebar from whatever lands there.

The build-docs subcommand runs the full pipeline in one step. From a single raw run it generates story pages, Explorer data, and bundles referenced media — no flags to get wrong:

Terminal window
npx executable-stories build-docs raw-run.json --site-dir ./my-docs

With an OpenAPI spec it also generates API coverage pages:

Terminal window
npx executable-stories build-docs raw-run.json \
--site-dir ./my-docs \
--openapi ./openapi.yaml

Then start the dev server:

Terminal window
cd my-docs
pnpm dev

Your generated story pages are at http://localhost:4321/stories/ and the Scenario Explorer is at http://localhost:4321/explorer/.

OutputLocation
Story pages (one per source file)src/content/docs/stories/
StoryReport JSON (Explorer data)public/stories/story-report.json
Scenario notes indexpublic/stories/notes-index.json
Copied screenshots/videospublic/stories/assets/
API coverage pages (if --openapi)src/content/docs/api/

The bundled Scenario Explorer (/explorer/) is a single browsable front door over the StoryReport JSON: a scenario list with status, a status filter, and a search box that matches titles, tags, and covers file paths — so you can type a product-code path and find the behavior that exercises it (the same code→scenario link the MCP get_scenarios_for_paths tool uses). Each scenario’s detail panel lists its steps, the paths it covers, and a business-context link when a scenario note exists.

For a stakeholder-first portal, generate docs with audience split and a baseline:

Terminal window
npx executable-stories build-docs raw-run.json \
--site-dir ./my-docs \
--audience-split \
--baseline ./my-docs/public/stories/story-report.json

If you need finer control over artifact placement, use format --format astro directly:

Terminal window
npx executable-stories format raw-run.json \
--format astro \
--output-dir ./my-docs/src/content/docs/stories

If your tests produce screenshots or other local assets, add --asset-mode copy so the formatter copies them into the site’s public directory with content-hashed filenames:

Terminal window
npx executable-stories format raw-run.json \
--format astro \
--output-dir ./my-docs/src/content/docs/stories \
--asset-mode copy

Each run produces a Markdown file with Starlight-compatible YAML frontmatter:

---
title: User Stories
description: 3 scenarios — passed
sidebar:
badge:
text: Passed
variant: success
---

The sidebar badge reflects the overall test status:

StatusBadgeColor
All passedPassedGreen
Any failedFailedRed
Any pendingPendingYellow
All skippedSkippedYellow

Inside the Markdown, scenarios are grouped by source file and use Gherkin-style formatting (bold Given/When/Then keywords, tags inline, status indicators).

You can generate the Astro site alongside your regular HTML and Markdown reports in a single command:

Terminal window
npx executable-stories format raw-run.json \
--format astro,html,markdown

The Astro output goes to --output-dir, while HTML and Markdown go to --output-dir with extensions as usual.

When --asset-mode copy is set, the formatter:

  1. Scans the generated Markdown for local image and video references
  2. Copies each file to public/stories/assets/ with a content hash appended to the filename
  3. Rewrites the paths in the Markdown to point at the hashed copies

URLs, data URIs, and paths inside fenced code blocks are left alone. If a referenced file is missing, the formatter fails by default. Pass --allow-missing-assets to get a warning instead.

The scaffolded site is a standard Astro project. Build it and deploy the dist/ directory:

Terminal window
pnpm build

Works with Vercel, Netlify, GitHub Pages, Cloudflare Pages, or any static host. See Astro’s deployment guides for platform-specific instructions.

Terminal window
npx executable-stories init-astro [directory]
OptionDefaultDescription
directorystory-docsWhere to create the site
--forcefalseOverwrite if directory exists
--updatefalseRefresh framework files (components, styles, explorer) without touching your content or config
Terminal window
npx executable-stories build-docs <raw-run.json> --site-dir <dir> [options]
OptionDefaultDescription
--site-dir(required)Root of the init-astro-scaffolded site
--openapiPath to an OpenAPI spec for API coverage pages
--baselinePrevious story-report.json to generate a what’s-changed view
--audience-splitfalseSplit generated pages into engineer/stakeholder sections
--no-synthesize-storiesfalseSkip synthesizing story metadata from test structure
Terminal window
npx executable-stories format <input> --format astro [options]
OptionDefaultDescription
--output-dirreportsWhere to write the .md files
--output-nametest-resultsBase filename (without extension)
--asset-mode(none)Set to copy to copy local assets
--allow-missing-assetsfalseWarn instead of failing on missing assets