Skip to navigation

Standalone tests

Standalone JSON or YAML files help you see the entirety of the spec and keep it in a separate, machine-readable format. They’re useful for:

  • Complex test suites that need version control
  • Automated test generation and processing
  • Integration with CI/CD pipelines
  • Sharing tests across projects

However, they make it harder to maintain strict parallelism with documentation, so consider your use case carefully.

Test specs in standalone JSON or YAML files use the following basic structure:

{
"specId": "spec-id",
"description": "Spec Description",
"tests": [
{
"testId": "test-id",
"description": "Test Description",
"steps": [
{
"stepId": "step-id",
"description": "Step description. Each step has one action, such as `goTo`, `find`, or `httpRequest`.",
"goTo": "https://www.example.com"
}
]
}
]
}

For comprehensive options, see specification.

Editor support

Editors that read JSON Schema, such as VS Code, offer completion and validation. To turn that on, add a $schema property to a spec, step, context, or config. Doc Detective ignores the value when it runs. Your editor loads the schema from it. Point it at a schema file the editor can reach, such as the URL below or a local copy.

{
"$schema": "https://raw.githubusercontent.com/doc-detective/doc-detective/main/src/common/src/schemas/src_schemas/spec_v3.schema.json",
"tests": [
{
"steps": [
{
"wait": 1
}
]
}
]
}

Swap spec_v3 for step_v3, context_v3, or config_v3 to match the file.

Example

Here’s an example test for performing a Google search and saving a screenshot of the results:

{
"tests": [
{
"steps": [
{
"goTo": "https://www.google.com"
},
{
"find": {
"selector": "[title=Search]",
"click": true
}
},
{
"type": ["American Shorthair kittens", "$ENTER$"]
},
{
"wait": 5000
},
{
"screenshot": "search-results.png"
}
]
}
]
}