> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.doc-detective.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.doc-detective.com/_mcp/server.

# test

> A Doc Detective test.

A Doc Detective test.

## Referenced In

* [specification](/reference/schemas/specification)

## Fields

| Field              | Type                                                                     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | Default |
| :----------------- | :----------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------ |
| testId             | string                                                                   | Optional. Unique identifier for the test.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | —       |
| description        | string                                                                   | Optional. Description of the test.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | —       |
| contentPath        | string                                                                   | Optional. Path to the content that the test is associated with.                                                                                                                                                                                                                                                                                                                                                                                                                                               | —       |
| detectSteps        | boolean                                                                  | Optional. Whether or not to detect steps in input files based on markup regex.                                                                                                                                                                                                                                                                                                                                                                                                                                | `true`  |
| autoScreenshot     | boolean                                                                  | Optional. If `true`, captures a screenshot after every step in this test that runs in a browser. Overrides `autoScreenshot` set at the spec or config level. When unset, defers to the spec level, then the config level.                                                                                                                                                                                                                                                                                     | —       |
| autoRecord         | boolean                                                                  | Optional. If `true`, records a video of every browser context in this test. Overrides `autoRecord` set at the spec or config level. When unset, defers to the spec level, then the config level.                                                                                                                                                                                                                                                                                                              | —       |
| annotationDefaults | object([Annotation defaults](/reference/schemas/annotation-defaults))    | Optional. Default visual theme for annotations in this test. Overrides `annotationDefaults` set at the spec or config level. When unset, defers to the spec level, then the config level.                                                                                                                                                                                                                                                                                                                     | —       |
| runOn              | array of object([context](/reference/schemas/context))                   | Optional. Contexts to run the test in. Overrides contexts defined at the config and spec levels.                                                                                                                                                                                                                                                                                                                                                                                                              | —       |
| openApi            | array of unknown                                                         | Optional. No description provided.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | —       |
| if                 | one of: - string - array of string                                       | Optional. A condition expression, or an array of expressions combined with logical AND.                                                                                                                                                                                                                                                                                                                                                                                                                       | —       |
| onPass             | array of object([routing](/reference/schemas/routing))                   | Optional. Routing entries evaluated after this test passes. `continue` (the default) and `stop` are honored at runtime: `stop: test` is a no-op (the test already finished), `stop: spec` stops the spec's remaining tests, and `stop: run` is deferred (currently behaves as `spec`). `goToTest` jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded); `retry` and `goToStep` are not applicable at test scope.                                              | —       |
| onFail             | array of object([routing](/reference/schemas/routing))                   | Optional. Routing entries evaluated after this test fails. `continue` and `stop` are honored at runtime: `stop: test` (the default) is a no-op (the test already finished, so a failing test does not stop its siblings), `stop: spec` stops the spec's remaining tests, and `stop: run` is deferred (currently behaves as `spec`). `goToTest` jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded); `retry` and `goToStep` are not applicable at test scope. | —       |
| onWarning          | array of object([routing](/reference/schemas/routing))                   | Optional. Routing entries evaluated after this test produces a warning. `continue` (the default) and `stop` are honored at runtime: `stop: test` is a no-op (the test already finished), `stop: spec` stops the spec's remaining tests, and `stop: run` is deferred (currently behaves as `spec`). `goToTest` jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded); `retry` and `goToStep` are not applicable at test scope.                                  | —       |
| onSkip             | array of object([routing](/reference/schemas/routing))                   | Optional. Routing entries evaluated after this test is skipped. `continue` (the default) and `stop` are honored at runtime: `stop: test` is a no-op (the test already finished), `stop: spec` stops the spec's remaining tests, and `stop: run` is deferred (currently behaves as `spec`). `goToTest` jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded); `retry` and `goToStep` are not applicable at test scope.                                          | —       |
| before             | string                                                                   | Optional. Path to a test specification to perform before this test, while maintaining this test's context. Useful for setting up testing environments. Only the `steps` property is used from the first test in the setup spec.                                                                                                                                                                                                                                                                               | —       |
| after              | string                                                                   | Optional. Path to a test specification to perform after this test, while maintaining this test's context. Useful for cleaning up testing environments. Only the `steps` property is used from the first test in the cleanup spec.                                                                                                                                                                                                                                                                             | —       |
| steps              | array of object                                                          | Optional. Steps to perform as part of the test. Performed in the sequence defined. If one or more actions fail, the test fails. By default, if a step fails, the test stops and the remaining steps are not executed.                                                                                                                                                                                                                                                                                         | —       |
| durationMs         | integer                                                                  | ReadOnly. Total time this test took, in milliseconds: the sum of the per-context durations. A sum rather than a wall-clock span, because this test's contexts share a concurrent pool with every other test's. Present only in test results. System-populated. Minimum: 0                                                                                                                                                                                                                                     | —       |
| contexts           | array of object([Resolved context](/reference/schemas/resolved-context)) | ReadOnly. Resolved contexts to run the test in. This is a resolved version of the `runOn` property. It is not user-defined and should not be used in test specifications.                                                                                                                                                                                                                                                                                                                                     | —       |

## Examples

```json
{
  "steps": [
    {
      "checkLink": "https://www.duckduckgo.com"
    }
  ]
}
```

```json
{
  "steps": [
    {
      "goTo": {
        "url": "https://www.duckduckgo.com"
      }
    },
    {
      "find": {
        "selector": "[title=Search]",
        "click": true,
        "type": {
          "keys": [
            "shorthair cats",
            "$ENTER$"
          ]
        }
      }
    }
  ]
}
```

```json
{
  "testId": "Do all the things! - Test",
  "description": "This test includes every property across all actions.",
  "before": "setup.json",
  "after": "cleanup.json",
  "runOn": [
    {
      "platforms": [
        "linux"
      ],
      "browsers": {
        "name": "firefox",
        "window": {},
        "viewport": {}
      }
    }
  ],
  "steps": [
    {
      "loadVariables": ".env"
    },
    {
      "runShell": {
        "command": "echo",
        "args": [
          "$USER"
        ],
        "maxVariation": 0,
        "overwrite": "aboveVariation"
      },
      "variables": {}
    },
    {
      "checkLink": {
        "url": "https://www.duckduckgo.com"
      }
    },
    {
      "httpRequest": {
        "method": "post",
        "url": "https://reqres.in/api/users",
        "request": {
          "body": {
            "name": "morpheus",
            "job": "leader"
          }
        },
        "response": {
          "body": {
            "name": "morpheus",
            "job": "leader"
          }
        },
        "statusCodes": [
          200,
          201
        ],
        "maxVariation": 0,
        "overwrite": "aboveVariation"
      },
      "variables": {}
    },
    {
      "goTo": {
        "url": "https://www.duckduckgo.com"
      }
    },
    {
      "find": {
        "selector": "[title=Search]",
        "elementText": "Search",
        "timeout": 10000,
        "moveTo": true,
        "click": true,
        "type": {
          "keys": [
            "shorthair cat"
          ]
        }
      },
      "variables": {}
    },
    {
      "type": {
        "keys": [
          "$ENTER$"
        ]
      }
    },
    {
      "screenshot": {
        "maxVariation": 0,
        "overwrite": "aboveVariation"
      }
    }
  ],
  "detectSteps": true
}
```

```json
{
  "testId": "c61b02e8-7485-44d3-8065-f873673379c6",
  "openApi": [
    {
      "descriptionPath": "https://www.acme.com/openapi.json",
      "server": "https://api.acme.com",
      "validateAgainstSchema": "both",
      "useExample": "none",
      "exampleKey": "",
      "name": "Acme"
    }
  ],
  "steps": [
    {
      "httpRequest": {
        "openApi": {
          "operationId": "getUserById",
          "validateAgainstSchema": "both",
          "useExample": "none",
          "exampleKey": ""
        },
        "request": {
          "parameters": {
            "id": 123
          }
        },
        "response": {},
        "maxVariation": 0,
        "overwrite": "aboveVariation"
      },
      "variables": {}
    }
  ],
  "detectSteps": true
}
```

```json
{
  "annotationDefaults": {
    "color": "#E11D48",
    "strokeWidth": 3,
    "badge": {
      "background": "#E11D48",
      "color": "#FFFFFF"
    }
  },
  "steps": [
    {
      "screenshot": {
        "path": "a.png",
        "annotations": [
          {
            "outline": "#submit"
          }
        ]
      }
    }
  ]
}
```