Skip to navigation

test

A Doc Detective test.

Referenced In

Fields

FieldTypeDescriptionDefault
$schemastringOptional. JSON Schema URL for editor support. Doc Detective ignores it.

Minimum length: 1
—
testIdstringOptional. Unique identifier for the test.—
descriptionstringOptional. Description of the test.—
contentPathstringOptional. Path to the content that the test is associated with.—
publicVariablesarray of stringOptional. Environment variables whose values Doc Detective shows in output. By default, Doc Detective masks the value of every variable a run substitutes or loads, and of any variable whose name contains TOKEN, SECRET, PASSWORD, API_KEY, PRIVATE_KEY, or CREDENTIAL, as ***NAME***. A name listed on the config, any spec, or any test is public for the whole run. * matches any characters, so ["*"] turns masking off.—
detectStepsbooleanOptional. Whether or not to detect steps in input files based on markup regex.true
badgebooleanOptional. If true, Doc Detective maintains a shields.io “Last verified” badge image on the line immediately before this test’s inline test statement, updating it with today’s date whenever the test PASSes and leaving the badge untouched (aging) on any other result. No testId is required to opt in — the test is anchored to its write-back by source location (location), not by name. Only applies to tests detected from an inline test statement (markdown/MDX, AsciiDoc, HTML, DITA); has no effect on tests authored directly in a JSON or YAML spec file, which have no comparable “line above” to anchor a badge to.—
locationobjectReadOnly. Source location where this test’s inline test statement was detected in the original file. System-populated metadata; should not be set manually. Setting it by hand on a JSON/YAML spec test is unsupported: if that test also sets badge: true and its contentPath resolves to a writable format, the write-back writer treats the hand-set location as genuine and may write into that line.—
autoScreenshotbooleanOptional. Defaults to true. If not false, captures a screenshot after every step that drives a browser, native app, or device, headless included, unless the step defines its own screenshot, in this test. Overrides autoScreenshot set at the spec or config level. When unset, defers to the spec level, then the config level. While this is on, the runFolder reporter runs even if reporters leaves it out.—
autoRecordbooleanOptional. Defaults to true. If not false, records a video of every context that drives a browser, native app, or device in this test. Overrides autoRecord set at the spec or config level. When unset, defers to the spec level, then the config level. While this is on, the runFolder reporter runs even if reporters leaves it out.—
annotationDefaultsobject(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.—
runOnarray of object(context)Optional. Contexts to run the test in. Overrides contexts defined at the config and spec levels.—
openApiarray of unknownOptional. No description provided.—
ifone of:
- string
- array of string
Optional. A condition expression, or an array of expressions combined with logical AND.—
onPassarray of object(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), and stop: spec stops the spec’s remaining tests. goToTest jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded). Each entry is one of continue, stop: "test", stop: "spec", or goToTest.—
onFailarray of object(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), and stop: spec stops the spec’s remaining tests. goToTest jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded). Each entry is one of continue, stop: "test", stop: "spec", or goToTest.—
onWarningarray of object(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), and stop: spec stops the spec’s remaining tests. goToTest jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded). Each entry is one of continue, stop: "test", stop: "spec", or goToTest.—
onSkiparray of object(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), and stop: spec stops the spec’s remaining tests. goToTest jumps to the named test within the spec (unknown target -> a FAIL marker + stop; cycles are bounded). Each entry is one of continue, stop: "test", stop: "spec", or goToTest.—
beforestringOptional. 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.—
afterstringOptional. 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.—
stepsarray of object(step)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.—
resultstringReadOnly. Outcome of this test. Doc Detective populates it. You never set it yourself.

Accepted values: PASS, FAIL, WARNING, SKIPPED
—
resultDescriptionstringReadOnly. Why this test had its outcome. Doc Detective populates it. You never set it yourself.—
durationMsintegerReadOnly. 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
—
visitintegerReadOnly. Which run of this test this report is, when a goToTest routing entry ran it again. Present only in test results, from the second run on. System-populated.

Minimum: 2
—
contextsarray of object(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

{
"steps": [
{
"checkLink": "https://www.duckduckgo.com"
}
]
}
{
"steps": [
{
"goTo": {
"url": "https://www.duckduckgo.com"
}
},
{
"find": {
"selector": "[title=Search]",
"click": true,
"type": {
"keys": [
"shorthair cats",
"$ENTER$"
]
}
}
}
]
}
{
"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
}
{
"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
}
{
"annotationDefaults": {
"color": "#E11D48",
"strokeWidth": 3,
"badge": {
"background": "#E11D48",
"color": "#FFFFFF"
}
},
"steps": [
{
"screenshot": {
"path": "a.png",
"annotations": [
{
"outline": "#submit"
}
]
}
}
]
}