Skip to content

Commit

Permalink
fix: make "Documentation Tests" page up-to-date (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna authored Aug 16, 2024
1 parent a6af1c4 commit 1bd1a65
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion runtime/manual/basics/testing/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ title: "Documentation Tests"
oldUrl: /runtime/manual/testing/documentation/
---

Deno supports type-checking your documentation examples.
Deno supports _type-checking_ your documentation examples.

:::info

No runtime behavior is tested for code snippets in documentation as of now.
Tracking issue:
[denoland/deno#4716](https://github.com/denoland/deno/issues/4716)

:::

This makes sure that examples within your documentation are up to date and
working.
Expand All @@ -25,13 +33,32 @@ determined by the language identifier attribute which may be any of the
following:

- `js`
- `javascript`
- `mjs`
- `cjs`
- `jsx`
- `ts`
- `typescript`
- `mts`
- `cts`
- `tsx`

If no language identifier is specified then the language is inferred from media
type of the source document that the code block is extracted from.

Another attribute supported is `ignore`, which tells the test runner to skip
type-checking the code block.

````ts
/**
* # Does not pass type check
*
* ```typescript ignore
* const x: string = 42;
* ```
*/
````

If this example was in a file named foo.ts, running `deno test --doc foo.ts`
will extract this example, and then type-check it as a standalone module living
in the same directory as the module being documented.
Expand Down

0 comments on commit 1bd1a65

Please sign in to comment.