Skip to main content
The test schema defines a single test that Doc Detective can execute. Tests contain steps that perform actions like navigating to URLs, clicking elements, and validating content.

Schema Reference

testId
string
Unique identifier for the test. Auto-generated if not provided.
description
string
Description of the test. Useful for understanding what the test validates.
contentPath
string
Path to the content that the test is associated with. Useful for tracking which documentation page this test validates.

Steps

steps
step[]
required
Array of steps to execute in the test. Each step performs a specific action.See the Step Schema for detailed step options.

Test Execution

detectSteps
boolean
default:true
Whether or not to detect steps in input files based on markup regex.
runOn
context[]
Contexts to run the test in. Overrides contexts defined at the config and spec levels.See the Context Schema for more details.
before
string | string[]
Path(s) to test specifications to run before this test. Useful for test-specific setup.
after
string | string[]
Path(s) to test specifications to run after this test. Useful for test-specific cleanup.

OpenAPI Integration

openApi
object[]
OpenAPI descriptions to use for this test. Enables testing of API endpoints defined in OpenAPI specifications.

Simple Example

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

Interactive Example

{
  "testId": "search-functionality-test",
  "description": "Test the search functionality on DuckDuckGo",
  "steps": [
    {
      "goTo": {
        "url": "https://www.duckduckgo.com"
      }
    },
    {
      "find": {
        "selector": "[title=Search]",
        "click": true,
        "type": {
          "keys": [
            "shorthair cats",
            "$ENTER$"
          ]
        }
      }
    }
  ]
}

Complete Example

{
  "testId": "comprehensive-test-example",
  "description": "A comprehensive test showing multiple step types",
  "contentPath": "docs/getting-started.md",
  "detectSteps": true,
  "before": "setup.json",
  "after": "cleanup.json",
  "runOn": [
    {
      "platforms": ["linux"],
      "browsers": {
        "name": "firefox",
        "headless": true
      }
    }
  ],
  "steps": [
    {
      "loadVariables": ".env"
    },
    {
      "checkLink": {
        "url": "https://www.example.com"
      }
    },
    {
      "httpRequest": {
        "method": "post",
        "url": "https://api.example.com/users",
        "request": {
          "body": {
            "name": "John Doe",
            "email": "[email protected]"
          }
        },
        "statusCodes": [200, 201]
      }
    },
    {
      "goTo": {
        "url": "https://www.example.com"
      }
    },
    {
      "find": {
        "selector": "#search-input",
        "click": true,
        "type": {
          "keys": ["search query"]
        }
      }
    },
    {
      "screenshot": {
        "path": "search-results.png",
        "maxVariation": 0.1
      }
    }
  ]
}

OpenAPI Example

{
  "testId": "api-test-with-openapi",
  "openApi": [
    {
      "name": "MyAPI",
      "descriptionPath": "https://api.example.com/openapi.json",
      "server": "https://api.example.com",
      "validateAgainstSchema": "both",
      "useExample": "none"
    }
  ],
  "steps": [
    {
      "httpRequest": {
        "openApi": {
          "operationId": "getUserById"
        },
        "request": {
          "parameters": {
            "id": 123
          }
        }
      }
    }
  ]
}

Build docs developers (and LLMs) love