You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/get-started/tests/index.mdx
+177-3Lines changed: 177 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,15 @@ DITA supports two syntax options:
160
160
161
161
Attribute values are automatically converted to the appropriate type: booleans (`detectSteps=false`), numbers (`wait=500`), and strings. You can use dot notation for nested objects—for example, `<?doc-detective step httpRequest.url="https://api.example.com" httpRequest.method="GET" ?>` creates a nested `httpRequest` object with `url` and `method` properties.
162
162
163
+
You can also use HTML comment syntax as an alternative to processing instructions:
164
+
165
+
- Test comments: `<!-- test testId="my-test" detectSteps=false -->`
- Ignore blocks: `<!-- test ignore start -->` and `<!-- test ignore end -->`
169
+
170
+
HTML comments and processing instructions work identically. You can use whichever fits your documentation workflow better, or mix them in the same file.
171
+
163
172
> **Note:** DITA isn't enabled by default. To use DITA detection, add `"dita"` to your config's `fileTypes` array or define custom patterns. See the [config reference](/docs/references/schemas/config) for details.
164
173
165
174
#### Examples
@@ -243,7 +252,9 @@ Detected tests are useful for keeping your tests in sync with your documentation
243
252
244
253
> You can mix detected tests with [inline tests](#inline-json-or-yaml) to declare steps that might not be covered in your content, such starting or stopping a recording.
245
254
246
-
Doc Detective includes several default markup patterns for Markdown files. Here are all the built-in patterns:
255
+
Doc Detective includes default markup patterns for Markdown and DITA files. Here are the built-in patterns:
256
+
257
+
#### Markdown patterns
247
258
248
259
````json
249
260
{
@@ -329,8 +340,78 @@ Doc Detective includes several default markup patterns for Markdown files. Here
- Action: Types the specified text into the active element
486
+
487
+
**runCode**: Detects code blocks in supported languages and executes the code.
488
+
489
+
- Pattern: Code blocks with `bash`, `python`, `py`, `javascript`, or `js` outputclass (excluding those marked with `testIgnore`)
490
+
- Action: Executes the code in the specified language (marked as unsafe)
491
+
374
492
The `regex` property defines the regular expression patterns to match, and the `actions` property defines the actions to perform when the pattern is detected. With the default configuration, Doc Detective would take the following Markdown and generate tests automatically:
375
493
376
494
Markdown:
@@ -415,6 +533,58 @@ Detected tests:
415
533
}
416
534
```
417
535
536
+
**DITA example with detected tests:**
537
+
538
+
```xml
539
+
<?xml version="1.0" encoding="UTF-8"?>
540
+
<!DOCTYPEtopic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
541
+
<topicid="getting-started">
542
+
<title>Getting Started</title>
543
+
<!-- test testId="dita-detected-test" detectSteps=true -->
544
+
<body>
545
+
<p>To get started,</p>
546
+
<ol>
547
+
<li>Go to <xrefhref="https://console.acme.com">Acme Console</xref>.</li>
548
+
<li>Click <b>Search</b>.</li>
549
+
<li>Type "American Shorthair kittens".</li>
550
+
</ol>
551
+
<p>Check out our <xrefhref="https://docs.example.com">documentation</xref> for more information.</p>
You can extend or override the default patterns by defining custom markup patterns in your configuration:
@@ -446,7 +616,7 @@ You can extend or override the default patterns by defining custom markup patter
446
616
447
617
#### Other file types
448
618
449
-
Doc Detective also includes default configurations for HTML and AsciiDoc files, though these only include inline statement patterns for test definitions and don't include markup patterns for detected tests:
619
+
Doc Detective also includes default configurations for HTML and AsciiDoc files. These currently only include inline statement patterns for test definitions and don't include markup patterns for detected tests:
450
620
451
621
**HTML files** (`.html`, `.htm`):
452
622
@@ -458,11 +628,15 @@ Doc Detective also includes default configurations for HTML and AsciiDoc files,
458
628
- Uses AsciiDoc comment syntax for inline test statements
459
629
- Example: `// (test { "testId": "my-test" })`
460
630
631
+
**DITA files** (`.dita`, `.ditamap`, `.xml`):
632
+
633
+
DITA includes both inline statement patterns (processing instructions and HTML comments) and markup patterns for detected tests. See the [DITA inline statements](#inline-json-or-yaml) and [default markup patterns](#detected-tests) sections above for complete documentation.
634
+
461
635
To add detected test functionality to HTML or AsciiDoc files, you would need to define custom markup patterns in your configuration similar to the Markdown examples above.
462
636
463
637
### Default actions
464
638
465
-
If you only need to perform simple steps, you can define actions using a shorthand of only specifying the action name. Doc Detective uses default actions, substituting the first capture group (or if there are no capture groups, the entire match) from the regex pattern into the most common location for the action. In the above example, the config generates a `goTo` action for every Markdown hyperlink preceded by a navigation verb.
639
+
If you only need to perform basic steps, you can define actions using a shorthand of only specifying the action name. Doc Detective uses default actions, substituting the first capture group (or if there are no capture groups, the entire match) from the regex pattern into the most common location for the action. In the above example, the config generates a `goTo` action for every Markdown hyperlink preceded by a navigation verb.
Copy file name to clipboardExpand all lines: docs/references/schemas/config.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,14 @@ Field | Type | Description | Default
10
10
$schema | string | Optional. JSON Schema for this object.<br/><br/>Accepted values: `https://raw.githubusercontent.com/doc-detective/common/refs/heads/main/dist/schemas/config_v3.schema.json` |
11
11
configId | string | Optional. Identifier for the configuration. |
12
12
configPath | string | ReadOnly. Path to the configuration file. |
13
-
input | one of:<br/>- string<br/>- array of string | Optional. Path(s) to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. | `.`
13
+
input | one of:<br/>- string<br/>- array of string | Optional. Paths to test specifications and documentation source files. May be paths to specific files or to directories to scan for files. | `.`
14
14
output | string | Optional. Path of the directory in which to store the output of Doc Detective commands. If a file path is specified, Doc Detective attempts to honor the file name specified, but file path behavior is controlled by the configured reporters. | `.`
15
15
recursive | boolean | Optional. If `true` searches `input`, `setup`, and `cleanup` paths recursively for test specifications and source files. | `true`
16
16
relativePathBase | string | Optional. Whether paths should be interpreted as relative to the current working directory (`cwd`) or to the file in which they're specified (`file`).<br/><br/>Accepted values: `cwd`, `file` | `file`
17
17
loadVariables | string | Optional. Load environment variables from the specified `.env` file. |
18
18
origin | string | Optional. Default protocol and domain to use for relative URLs. |
19
-
beforeAny | one of:<br/>- string<br/>- array of string | Optional. Path(s) to test specifications to perform before those specified by `input`. Useful for setting up testing environments. |
20
-
afterAll | one of:<br/>- string<br/>- array of string | Optional. Path(s) to test specifications to perform after those specified by `input`. Useful for cleaning up testing environments. |
19
+
beforeAny | one of:<br/>- string<br/>- array of string | Optional. Paths to test specifications to perform before those specified by `input`. Useful for setting up testing environments. |
20
+
afterAll | one of:<br/>- string<br/>- array of string | Optional. Paths to test specifications to perform after those specified by `input`. Useful for cleaning up testing environments. |
21
21
detectSteps | boolean | Optional. Whether or not to detect steps in input files based on defined markup. | `true`
22
22
allowUnsafeSteps | boolean | Optional. Whether or not to run potentially unsafe steps, such as those that might modify files or system state. |
23
23
logLevel | string | Optional. Amount of detail to output when performing an operation.<br/><br/>Accepted values: `silent`, `error`, `warning`, `info`, `debug` | `info`
0 commit comments