Markdown input format
Markdown is the most commonly used format for documentation sites. Doc Detective supports standard Markdown, MDX, and various Markdown flavors including GitHub Flavored Markdown.
File extensions
Doc Detective processes Markdown files with the following extensions:
.md.markdown.mdx
Inline test syntax
Markdown files support multiple comment styles for inline tests:
JSX-style comments (recommended for MDX):
HTML comments:
Markdown link comments:
All three styles work identically. Choose the style that fits your documentation workflow. MDX doesn’t support HTML comments, so use the JSX-style or link style in .mdx files.
Doc Detective reads statements from comments only. A statement inside a code block or inline code is part of the sample, not a test.
Best practices
- Use bold text for UI elements you want to interact with (buttons, menu items, etc.)
- Use explicit navigation verbs (go to, navigate to, etc.) before links you want to open
- Add the
.screenshotclass to images you want to capture as screenshots - Combine inline and detected tests for comprehensive coverage
- Use
testIgnorein code blocks that should not be executed as tests
Detected test patterns
With step detection on, Markdown files detect the steps listed in What gets detected. The definitions match parsed Markdown, so text inside code blocks and inline code never becomes a step. Links, images, and bold text written as HTML, such as <a href> and <strong>, count too, as do lowercase JSX tags in MDX.
Default Markdown definitions
The built-in definitions are selectors:
Pattern descriptions
A bold phrase is its rendered text, so **`Save`** finds Save. A screenshot’s attribute list can sit right after the image, as in {.screenshot} or {: .screenshot}.
An HTTP request block holds the method and URL on its first line, then any headers, then a blank line and the body. A header’s value runs to the end of its line, spaces included:
To keep a code block from running, add testIgnore after its language, as in ```bash testIgnore.
Example with detected tests
Markdown input:
Detected tests:
Each link gets a checkLink step, including the one after “Go to”, and each bold phrase gets a find step, including the one after “Click”.
Combining inline and detected tests
You can mix inline test statements with detected tests for maximum flexibility:
In this example:
- The navigation and button clicks are detected automatically
- Specific form field typing is defined inline for precise control
detectSteps: trueenables detection within the test block
Next steps
- Learn about inline tests for manual test definition
- Learn about detected tests for automatic test generation
- See custom inputs to extend Markdown patterns