On this page
The short answerWhat Deno runsWhy Deno examples break or go untestedBuild a small documentation testCheck without executingCompare the scan with DenoSee API driftWriting conventions that keep examples testableTriage findingsWhere DocsAlive fitsThe sources we checkedFAQThe short answer
Run deno test --doc against the module and Markdown files that contain your examples. Give Markdown examples their own imports, grant only the permissions they need, and use assertions to test promised values. Use Deno’s doc-aware check flags when you want type-checking without execution, and review ignored examples separately.
In engine 0.6.3, DocsAlive does not run Deno or read JSDoc in source files. It runs supported TypeScript and JavaScript fences under Node, where Deno globals, import-map names and jsr: specifiers do not provide Deno behavior. A Deno global was classified as depends-on-context in the probe; an import-map name and a jsr: import produced runtime-error findings requiring review. The engine does not read Deno’s ignore attribute, and it skips shell lines beginning with deno as host-tool commands. Use Deno for Deno-specific examples and the scan for other supported blocks on the same pages.
What Deno runs
Deno’s documentation test guide describes deno test --doc as a way to evaluate fenced examples in JSDoc comments and Markdown files. It recognizes fences labeled js, javascript, mjs, cjs, jsx, ts, typescript, mts, cts and tsx. When a fence has no language identifier, Deno infers the language from the source document’s media type.
Each example becomes a pseudo test case named for its source file and line range. Deno runs it as a standalone module in the same directory as the documented module. That location matters for relative imports: write the path as it should resolve from the document containing the example.
Exports from a documented module are automatically imported under their exported names into that module’s own JSDoc examples. That convenience does not make those names available in a separate Markdown page. A Markdown example should import the module items it uses, even when a nearby JSDoc example can omit the same import.
A hashbang at the top of an example can declare Deno CLI flags. Deno validates those flags and forwards permission flags to the generated test. The example cannot receive broader permissions than the parent deno test command was granted. The ignore attribute skips a block; in the probe below, the ignored example was not type-checked either.
For type-checking without execution, deno check --doc checks code blocks in JSDoc as well as the code. deno check --doc-only checks documentation blocks in JSDoc and Markdown only. Deno’s documentation points to the former for JSDoc and the latter for Markdown. See the Deno check reference for the command’s scope.
Why Deno examples break or go untested
Deno makes documentation tests unusually cheap: one flag turns the examples in comments and Markdown into tests, with the same type checker the code uses. The failures in the probe below came from the details around that flag, not from the idea itself.
Markdown is not JSDoc. Inside a module's own JSDoc, exported names arrive without an import, so authors get used to writing examples that call the function directly. The same style copied into a Markdown page fails, because the automatic import applies to the documented module only. A reader who pastes the Markdown example into a new file hits the same missing name.
Permissions are a second contract. An example that reads an environment variable or the network can declare its permission in a hashbang, but the doc test never gets more than the parent command allows. A task that grants nothing turns a correct example into a failure, and a task that grants everything hides how much access the example really needs.
Ignored blocks age silently. The ignore attribute is the right tool for examples that cannot run in a test, such as one that sends a message or needs a real account. It also removes the block from type-checking, so a rename or a changed signature leaves the ignored example behind with no warning.
The plain check does not look at examples. A module that type-checks cleanly can still have broken examples, because the ordinary check reads the code, not the comments or the Markdown. The doc flags change that, but the file selection then decides what is covered, and in the probe a directory argument selected nothing for the doc-only check.
Expected values in comments are not checks. A comment that says what a call returns is helpful to a reader, but the doc test only fails when the code throws or an assertion fails. Examples that matter should assert their result.
Build a small documentation test
The following files are illustrative. The package name acme-slug is illustrative and is not a published package. The probe used Deno 2.9.8 and its bundled TypeScript 6.0.3.
Start with a configuration file that maps the assertion library and defines a task. The task names the module, README and documentation directory, and grants access to one environment variable.
{
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.0"
},
"tasks": {
"test:docs": "deno test --doc --allow-env=SLUG_MAX mod.ts README.md docs/"
}
}
The module has two executable JSDoc examples and one intentionally ignored example. Assertions make the first two examples fail if the returned values change. The ignored example needs separate review because the doc test does not check it.
/**
* Turn a title into a URL slug.
*
* @example Basic use
* ```ts
* import { assertEquals } from "@std/assert";
*
* assertEquals(slugify("Hello, World!"), "hello-world");
* ```
*/
export function slugify(title: string): string {
return title
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
}
/**
* Shorten a slug to at most `max` characters without cutting a word.
*
* @example
* ```ts
* import { assertEquals } from "@std/assert";
*
* const short = truncateSlug("testing-docs-examples-with-deno", 20);
* assertEquals(short, "testing-docs");
* ```
*
* @example Reading the limit from the environment (not run)
* ```ts ignore
* const max = Number(Deno.env.get("SLUG_MAX"));
* truncateSlug(slugify(Deno.args[0]), max);
* ```
*/
export function truncateSlug(slug: string, max: number): string {
if (slug.length <= max) return slug;
const cut = slug.slice(0, max + 1);
return cut.slice(0, cut.lastIndexOf("-"));
}
The illustrative README imports the module explicitly. That path is relative to the README, so it differs from the path a page inside docs/ needs.
# acme-slug
Make URL slugs from titles.
```ts
import { slugify } from "./mod.ts";
console.log(slugify("Release notes: v2.0"));
```
The first version of the usage page is broken on purpose. It assumes that Markdown receives the same automatic imports as the module’s own JSDoc. It also asks for an environment permission in the hashbang.
# Usage
Exported names are available without an import in a doc test:
```ts
import { assertEquals } from "@std/assert";
const slug = slugify("Docs That Run");
assertEquals(slug, "docs-that-run");
```
Read the limit from an environment variable:
```ts
#!/usr/bin/env -S deno run --allow-env=SLUG_MAX
const max = Number(Deno.env.get("SLUG_MAX") ?? "40");
console.log(truncateSlug(slugify("A very long title for a page"), max));
```
Plain JavaScript works too:
```js
const words = "one two three".split(" ");
console.log(words.length);
```
Run the module and Markdown examples together. This first command does not grant the environment permission; the missing imports are encountered first.
deno test --doc mod.ts README.md docs/
The excerpt below shows two of the three type errors. Because type-checking failed, no test ran in this attempt. A failure before execution is useful evidence, but it does not establish whether the remaining examples would pass at runtime.
TS2304 [ERROR]: Cannot find name 'slugify'.
const slug = slugify("Docs That Run");
~~~~~~~
at file:///.../docs/usage.md#5-11.ts:3:18
TS2304 [ERROR]: Cannot find name 'truncateSlug'.
console.log(truncateSlug(slugify("A very long title for a page"), max));
~~~~~~~~~~~~
at file:///.../docs/usage.md#14-19.ts:9:17
Found 3 errors.
error: Type checking failed.
Fix the page by importing each name where it is used. The path moves up from docs/ to the module. Keep the hashbang at the start of the environment example.
# Usage
Markdown pages need their own import of the module:
```ts
import { assertEquals } from "@std/assert";
import { slugify } from "../mod.ts";
const slug = slugify("Docs That Run");
assertEquals(slug, "docs-that-run");
```
Read the limit from an environment variable:
```ts
#!/usr/bin/env -S deno run --allow-env=SLUG_MAX
import { slugify, truncateSlug } from "../mod.ts";
const max = Number(Deno.env.get("SLUG_MAX") ?? "40");
console.log(truncateSlug(slugify("A very long title for a page"), max));
```
Plain JavaScript works too:
```js
const words = "one two three".split(" ");
console.log(words.length);
```
Running the earlier command again gets past the import errors. Five tests pass, but the environment example fails because the parent command did not receive the permission requested by the hashbang.
./docs/usage.md#15-22.ts => ./docs/usage.md#15-22.ts:2:6
error: NotCapable: Can't escalate parent thread permissions
FAILED | 5 passed | 1 failed
Grant the same narrow permission on the parent command, or use the task defined in the configuration. Both commands cover the same files in this illustration.
deno test --doc --allow-env=SLUG_MAX mod.ts README.md docs/
deno task test:docs
Both runs passed all six tests in the probe.
ok | 6 passed | 0 failed
A no-argument deno test --doc also found the README, usage page and module in this probe and ran six tests. Explicit paths remain useful when a team wants the intended coverage visible in its task definition.
Check without executing
The next commands demonstrate an important scope difference. In this probe, giving a directory to deno check --doc-only found no matching files. Naming the README and Markdown files checked their four blocks.
deno check --doc-only docs/
deno check --doc-only README.md docs/*.md
Read the warning and the individual checked paths together. A command that exits without checking the intended pages does not provide the coverage a reviewer may assume from its name.
Warning No matching files found.
Check README.md#5-10.ts
Check docs/usage.md#5-12.ts
Check docs/usage.md#15-22.ts
Check docs/usage.md#25-29.js
With no arguments, deno check --doc-only checked only the two JSDoc examples in the module in this probe. Check your own file selection and command output when you adopt the workflow. An ordinary deno check mod.ts checks the module but does not check its examples without the doc flags.
Type-checking and execution answer different questions. A type check can catch an unavailable exported name or an incompatible argument without exercising the example. An executed assertion can also catch a value that changed while remaining type-correct. The TypeScript guide and TypeDoc guide cover related documentation checks.
Compare the scan with Deno
Plan a scan of the illustrative repository with the following command. Planning alone does not execute blocks.
docsalive scan .
The plan found two pages and four blocks: the plain project’s docs/ directory plus the root README. It did not read the JSDoc in mod.ts. In a separate engine-driver run with the network off, the plain JavaScript block passed, while the TypeScript block using the Deno import-map name and the hashbang block failed as runtime-error findings needing review. The README TypeScript block ran on the probe machine’s Node 24, which can load a TypeScript file directly; the standard runner has Node 20, so do not rely on that result.
The distinction is especially important when a result looks like an API problem. A Deno-specific import may be valid for readers and still fail in Node. Conversely, a block that passes under Node does not prove that its Deno permission model or import map is correct.
| Deno feature | What deno test --doc does |
What the engine does in 0.6.3 |
|---|---|---|
| Module JSDoc | Finds eligible examples and supplies the module’s exports | Does not read JSDoc in source files |
| Markdown imports | Runs each example as a standalone module; imports must resolve from the document | Extracts supported Markdown fences and runs JavaScript with Node |
| Deno global | Uses Deno’s runtime | A Deno.env probe failed as depends-on-context |
Import map or jsr: |
Resolves Deno-supported imports | Probed import-map and jsr: imports failed as runtime-error |
| Hashbang permission | Validates flags and applies permission flags within the parent grant | Does not reproduce Deno’s permission behavior; the probe failed as runtime-error |
ignore |
Skips the example | Reads the first fence label and ran the ignored TypeScript probe |
Shell command beginning with deno |
Not evaluated; only the JavaScript and TypeScript fence languages listed above are run | Skips it as host-tool:deno |
For Deno globals, import maps, jsr: or npm: specifiers and permissions, keep deno test --doc as the authoritative execution check. A scan can still cover supported Python, shell, JSON and plain Node-compatible JavaScript on the same pages and classify findings for review. The JavaScript guide explains the Node-oriented side of that workflow.
The engine’s page selection also matters. It reads .md, .mdx and .markdown pages, not source-file comments. For a plain project with a top-level docs/ directory, the default is that directory plus the root README. Use the CLI reference to choose a narrower page scope when Deno-only pages produce results the scan cannot interpret.
See API drift
The next change is broken on purpose: it renames an exported function while leaving both the documentation and JSDoc examples unchanged.
-export function truncateSlug(slug: string, max: number): string {
+export function shortenSlug(slug: string, max: number): string {
The documentation task then failed type-checking with two errors. The Markdown import referred to an export that no longer existed, and the JSDoc example referred to the old automatically imported name.
TS2305 [ERROR]: Module '"file:///.../mod.ts"' has no exported member 'truncateSlug'.
import { slugify, truncateSlug } from "../mod.ts";
~~~~~~~~~~~~
at file:///.../docs/usage.md#15-22.ts:1:19
TS2304 [ERROR]: Cannot find name 'truncateSlug'.
const short = truncateSlug("testing-docs-examples-with-deno", 20);
~~~~~~~~~~~~
at file:///.../mod.ts#22-28.ts:4:19
Found 2 errors.
error: Type checking failed.
An ordinary check of the module alone passed after this rename because the implementation remained valid. The ignored example still used the old function and did not produce an error. That is the practical cost of an ignored block: it can continue to look authoritative to readers while falling behind the API.
Keep ignored examples rare, explain why they are ignored, and assign a review point when the reason changes. If an example illustrates a planned API rather than a current one, label it clearly and keep it out of a current-version test path.
Writing conventions that keep examples testable
These are conventions, not Deno rules, but each one removes a failure mode shown in this guide.
- Import explicitly in every Markdown example, with a path that resolves from the page's own folder. Readers copy Markdown examples into new files, and an explicit import is what makes the copy work.
- State results with an assertion from the standard library rather than in a comment, so the doc test can fail when the value changes.
- Keep the permission in a hashbang as narrow as the example needs, for example access to one named environment variable, and grant the same flag in the task that runs the doc tests.
- Use ignore only for examples that cannot run in a test, say in the prose why, and review those examples whenever the API they mention changes.
- Run the doc test from a task that names its files, so a reviewer can see what is covered, and run the same task in CI. The GitHub Actions guide and the GitLab CI guide show where such a step fits.
Triage findings
| Finding | Likely cause | What to do |
|---|---|---|
| Name missing in a Markdown example | The page relied on the JSDoc automatic import | Import the name in that block using a path relative to the page |
| Permission failure | The example asks for more than the parent test granted | Grant the same minimal permission to the parent task |
| No matching files in a doc-only check | The supplied directory did not select Markdown in the probe | Name the Markdown files and confirm the checked paths |
| Old API survives in an ignored block | The block was skipped and not type-checked | Review and update it, or make it executable |
| Node cannot resolve a Deno import | A Deno-specific block was sent to the engine’s Node runner | Verify it with Deno; treat the engine finding in that context |
depends-on-context for Deno |
The engine does not provide the Deno runtime | Use the Deno test and record the scan limitation |
| A passing command checked too little | Selection or an earlier skip reduced coverage | Review the selected files and skipped blocks before accepting the result |
Where DocsAlive fits
Use a Deno task in local development and CI for the examples whose correctness depends on Deno. Add the scan where the same documentation contains other supported block types, and review each classification rather than equating every failure with a documentation bug. A scan can run in a fresh container per page and report findings with their locations; its findings guide explains the categories.
The engine compares printed output only in Python pycon (>>>) sessions. For a Deno example whose result matters, write an assertion such as the ones above. A comment showing an expected value is useful to a reader, but it is not an assertion.
Use this checklist in a review or CI change:
Deno documentation test checklist
[ ] Select the module, README, and Markdown pages that contain examples.
[ ] Import every needed module item in each Markdown example.
[ ] Use assertions for values the example promises.
[ ] Keep each hashbang's permissions minimal.
[ ] Grant matching permissions to the parent Deno test task.
[ ] Run the doc test and investigate type errors before assuming tests ran.
[ ] Name Markdown files explicitly for the doc-only check and inspect coverage.
[ ] Review every ignored example separately for API drift.
[ ] Use Deno for Deno-specific imports, globals, and permissions.
[ ] Review scan findings in context and record skipped or unsupported coverage.
The sources we checked
These sources were read on November 15, 2026. Engine behavior was checked against engine 0.6.3 on the same day.
| Source | What it covers |
|---|---|
| Deno documentation tests | JSDoc and Markdown examples, imports, permissions and ignored blocks |
| Deno test reference | The test command and its options |
| Deno check reference | Documentation-aware type-checking |
| Deno testing | The broader Deno testing workflow |
FAQ
Does Deno test Markdown and JSDoc examples?
Yes. The doc test command evaluates eligible fenced examples in both. Exports from the documented module are automatically imported into its own JSDoc examples; Markdown examples need their own imports.
Does DocsAlive run Deno documentation tests?
No. Engine 0.6.3 does not run Deno or read JSDoc from source files. It runs supported fences under Node: a Deno global was classified as depends-on-context, while import-map and jsr: imports produced runtime-error findings in probes. It does not honor ignore, and it skips deno shell lines as host-tool commands.
Why did an example fail despite its permission hashbang?
The parent test command must also have the permission. An example cannot receive a broader grant than its parent. Give both the smallest permission the example needs.
Does an ignored example still get type-checked?
It did not in the probe. An ignored example retained a renamed function without an error, so review ignored content separately and use the attribute sparingly.
Is an ordinary Deno check enough?
Not for the examples in the probe. A check of the module alone passed after an API rename that broke its documentation. Use the doc-aware flags and confirm which files were selected.
What should a Deno guide use for expected values?
Use assertions in executable examples when a particular result matters. The test can then fail when the value changes, even if the example still parses and runs.




