v5.0.0
Doc Detective 5 makes a failed test fail the run, separates results from logs, and checks specs strictly. Before you upgrade, read Upgrade to Doc Detective 5. It lists every breaking change and what to do about each one. To stay on version 4 for now, pin it, as in npx doc-detective@4.
To migrate from Doc Detective 4:
- Move to a supported Node.js version, and set
node-versionexplicitly in CI. - In GitHub Actions workflows, switch to
doc-detective/github-action@v2. - Run your suite once with
--no-exit-on-fail, so the job stays green while you read the results. - Fix the invalid specs and failures the run reports.
- Update scripts that read the terminal output, report fields, or results paths.
- If an AI agent runs your tests, update its tools with
npx doc-detective@5 install agents. - Add
.doc-detective/to.gitignore, and remove--no-exit-on-failto turn the gate on.
Breaking changes
- Node.js: Version 5.0.0 dropped Node.js 22, which version 4 supported, and needed Node.js 24.15 or later. Starting with v5.2.1, Doc Detective needs Node.js 24.22.1 or later on the 24 line. On the 26 line, it needs 26.12.1 or later. That release also stopped supporting Node.js 25, which the v5.0.0 range allowed. Move to a supported Node.js version first, and set
node-versionexplicitly in CI, because GitHub-hosted runners default to Node.js 22. - Exit codes: A failed test exits
1. A run that tests nothing valid exits2, including an empty run, a run where every test skipped, and a run with an invalid spec. An interrupted run exits130or143. Let the exit code decide pass or fail, and pass--no-exit-on-failor setexitOnFail: falseto keep a job green while you triage. - Strict specs: An invalid spec stops the run before any test runs, instead of being skipped with a warning. Unknown keys on specs, steps, and custom file types make them invalid, and the error suggests the closest valid key. Keys that never did anything, such as
crawl,breakpoint, and an app’sworkingDirectory, are rejected too. Fix or delete each key the error names. - Checks that used to pass: A broken or empty
jq()query and a condition that’s only text, such as an unset$VARIABLE, now evaluate to false. Object-shapedassertionsfail the step. A step with two actions, a duplicatetestId, and a missingbeforeorafterfile make the spec invalid. Run your suite and fix what it reports. - Routing handlers: A routing entry that names an action Doc Detective can’t perform at that scope makes the spec invalid. On a step, use
stop: "test". To skip a spec’s remaining tests, move the handler to the test and usestop: "spec". - Step values: Timeouts that limit how long an operation runs start at
1, and waits can’t be negative."browser": "edge"and the device fieldsorientation,udid, andproviderare rejected. URLs must start with a variable,http://,https://, or/, and request header values must be strings."click": trueis invalid, so quote text you want to click, and afind.clickobject takes onlybuttonandduration. Fix each step the error names. - Test detection: Doc Detective parses each file before it detects tests. With step detection on, AsciiDoc and HTML detect steps the way Markdown does, and DITA detects more step types. Markdown code blocks tagged
pyorjsbecomerunCodesteps, and capitalized typing instructions such asType "kittens"becometypesteps. Code samples andjsoncode blocks no longer produce steps. Compare--dry-runoutput from version 4 and version 5, or setdetectSteps: falseto turn off step detection. - Results and logs: Only results go to stdout. Logs, warnings, hints, and report notices go to stderr without level labels such as
(INFO), and the terminal summary has a new format. Read results with--json,--plain, or--outputinstead of parsing the summary, and redirect with2>&1to collect both streams. - Report contents: JUnit test cases are named after test and context IDs, so your CI’s test history restarts once. The Markdown and HTML verdicts count tests, and failure and skip messages are reworded. Each step in the results shows its effective object form, so read
goTo.urlinstead ofgoTo. Some names changed with no alias, such as$$stdioMatchedto$$stdioMatchesand a step’sautoScreenshottoautoScreenshotPath. Update scripts and outputs that read these values. - Output paths:
--outputandoutputalways name the JSON results file. Use the new--output-dirflag oroutputDirkey for a folder. A run no longer writestestResults-<timestamp>.jsonto the current directory. Read.doc-detective/runs/<runId>/testResults.jsoninstead. - Screenshots and recordings by default:
autoScreenshotandautoRecordare on unless you set them tofalse, so every run writes a run folder. To keep version 4’s behavior, set both tofalseor pass--no-auto-screenshot --no-auto-record. Add.doc-detective/to.gitignore. - Capture locations:
screenshot: true,screenshot: {}, andrecord: truewrite tooutputDirinstead of the current folder. Move existing reference images tooutputDir, or give the step apath. - Chrome by default: A context that names no browser runs Chrome first, and a
recordcontext with no browser runs headless Chrome. To keep a context on Firefox, namefirefoxin itsrunOnentry, and refresh reference images taken in another browser. - Masked environment variables: Logs, reports, results, and saved step output show environment variable values as
***NAME***. Browser screenshots blur elements that show a secret, and fields that receive a typed secret show dots. List variables that aren’t secret inpublicVariables. See Keep secrets out of logs, reports, and captures. - CLI flags: List flags such as
--reportersand--inputtake one comma-separated value, given once.--concurrent-runnersneeds a value, invalid flag values exit2, and each subcommand accepts only its own flags. Configreportersaccepts only exact reporter names, and an empty list means no reporters. - Removed commands and flags: The
doc-detective-lspanddoc-detective-runnerbins and theinstall-agentsalias are gone. Usedoc-detective lsp,doc-detective runner, anddoc-detective install agents.install agentsdrops-aand-s, so use--agentand--scope.installdrops--silent, so use-qor--log-level silent. - Config and environment: Doc Detective loads
.envfrom the current directory, and shell variables win over it. Pass--no-env-fileto skip it. Flags, the environment,.env, the project config, and the user config layer in one precedence order. New installs cache under XDG paths instead of~/.doc-detective, though an existing~/.doc-detectivekeeps working. Update CI cache paths, or setDOC_DETECTIVE_CACHE_DIR. - Environment variable values:
DOC_DETECTIVE_*on-or-off variables read0,false,no, andoffas off.DOC_DETECTIVE_DEBUGnow adds debug output to a run, so usedoc-detective debugfor the diagnostic dump. The telemetry notice prints once per machine on stderr. - Deprecations: The
runTestscommand,--logLevel,--exit-on-fail,DOC_DETECTIVE,DOC_DETECTIVE_RUNTIME_DEBUG, and thebeforeAnyconfig key still work with a warning. Replace them withrun,--log-level, nothing,DOC_DETECTIVE_CONFIG,DOC_DETECTIVE_DEBUG, andbeforeAll. Setting both an old and a new name exits2. - Agent tools: Agent tools installed for version 4 don’t handle the new exit codes and
--output. When a test fails, they can treat the exit code as a broken runner instead of reading the results. Update them withnpx doc-detective@5 install agentsafter you upgrade. Reinstall Gemini CLI and Qwen Code extensions. - JavaScript API: The package exports only
runTestsandgetRunner. It no longer exportsdetectTests,detectAndResolveTests,resolveTests,readFile, orresolvePaths, and thedoc-detective/clipath is gone.runTests()rejects invalid specs and returns an empty report instead ofnullwhen it finds no tests. Usedoc-detective --dry-runordoc-detective-commonin place of the removed exports. - GitHub Action: Use
doc-detective/github-action@v2to run CLI 5. The@v1tag stays on CLI 4. See Run in CI with the GitHub Action.
New features
- Added the
runcommand, which takes files and folders as arguments, as indoc-detective run ./docs. - Added output flags:
--jsonprints one JSON document,--plainprints one tab-separated line per test context, and-qor--quietshows only errors and a one-line verdict.--no-colorandNO_COLORturn off color, and--no-inputturns off every prompt. - Added a user config file,
.envloading, and file-based credentials throughapiKeyFile,apiTokenFile, andDOC_DETECTIVE_API_FILE. See the CLI reference. - Every failed step reports a
resultCodeofenvironment,drift, orassertion. A browser step that misses its element lists the closest elements inoutputs.nearMatchesand names them inresultHint. See Troubleshoot a failing or flaky test. - The run folder includes a Markdown summary,
testResults.md, beside the JSON and HTML results. The HTML report shows automatic screenshots and recordings. - Custom file types can use selectors to match parsed nodes, such as links, comments, and bold text, in Markdown, MDX, HTML, DITA, and AsciiDoc. A selector skips code samples, which regex patterns can’t.
runCodeacceptspyandjsas languages.- Pressing Ctrl+C says the run is stopping and caps cleanup at five seconds. A second Ctrl+C stops at once.
- The Linux Docker image includes Xvfb, so automatic recording can record headless Firefox.
- The language server reads inline statements the way a run does, including ignore blocks and custom file types’ statements.
Bug fixes
- Fixed the HTML report header, which showed a dash for every field. It now shows the run’s start time, ID, environment, and duration.
- Fixed detected HTTP requests that ended their headers at a header value with a space, such as
Content-Type: application/json; charset=utf-8. - Fixed DITA tests that detected two
goToand twocheckLinksteps from one external link. - A command that can’t start, for example because its
workingDirectorydoesn’t exist, says so instead of reporting exit code-2.