Reporters and artifacts
Every Doc Detective run produces output. That means a summary in your terminal, machine-readable results, and, when your tests capture them, screenshots and recordings. This guide covers choosing which reporters run, where each one writes its output, and how to fail a CI build.
For the full list of reporter and output options, see the config reference.
Before you begin
- Install Doc Detective and have a spec you can run.
- Know your output folder. Reporters that write files use the
outputDirconfig option (or the--output-dirflag), which defaults to the current directory. The GitHub Action sets it to the runner’s temporary directory instead. See Find reports and the run folder.
Step 1: Choose your reporters
Doc Detective ships six reporters: terminal, json, html, runFolder, junit, and markdown. By default, it runs terminal and runFolder. To choose a different combination, set the reporters option.
The run folder holds the screenshots and recordings Doc Detective takes by default. So the runFolder reporter runs whenever autoScreenshot or autoRecord is on, even if reporters leaves it out:
Doc Detective doesn’t look for tests in folders named .doc-detective. That keeps a run from testing the files an earlier run saved there.
On GitLab, point the test summary at the junit.xml file, and upload the run folder with it so the attachments resolve:
On GitHub Actions, append the Markdown summary to the job summary:
Select reporters on the command line:
Or set them in your config file so every run uses the same combination:
To keep the defaults, leave reporters out of your config. An empty list, "reporters": [], runs no reporters you choose, so the run prints no summary. While autoScreenshot or autoRecord is on, the run folder still archives the results. Set both to false to write nothing.
Each name must match one of the six built-in reporters exactly, in your config or in --reporters. Any other name, such as "JSON" or "htm", stops the run with exit code 2 and an error that lists the allowed names. In a config file, the error looks like this:
What every reporter lists
The terminal, markdown, and junit reporters list the same results in the same order: failures, then warnings, then skips. Each item is the deepest result with a reason of its own, named by its ID path:
Skipped steps that come after a failure in the same context don’t get a line of their own, whatever their reason. Instead, the failure adds a line such as 3 more steps skipped after the failure, with its count. To see why each of those steps skipped, open testResults.json or testResults.html in the run folder. See Find each report. A failed automatic recording can be the only reason a context failed, so it gets a line like a failed step.
An item shows its reason and, when the files exist, the step’s screenshot and the context’s recording. Terminal paths are absolute. Markdown and JUnit paths are relative to the file they’re in.
Every reporter that prints a verdict counts tests:
Read the JUnit report
Each spec is a test suite, and each test in each context is a test case. The case’s classname is the spec ID. Its name is <testId> › <contextId> — <description>:
- Attachments.
[[ATTACHMENT|<path>]]lines come first in<system-out>, on every case that isn’t skipped. The screenshot of the first step that didn’t pass comes first, then the context’s recording. Paths are relative to the folder that holdsjunit.xml. Azure DevOps resolves them from there. GitLab resolves them from the project folder, so keepjunit.xmlat the project root and add.doc-detective/toartifacts:paths, as in the example above. - Warnings. JUnit has no warning state, so the case passes, and each warning is a
Warning:line in<system-err>. - Skips. A skipped context is
<skipped message="<reason>"><reason></skipped>. A skipped step in a case that ran is aSkipped:line in<system-out>. - Properties. Each suite has a
timestampand<properties>with the run ID and the run’s environment. They include only the fields the report has.
Read the Markdown summary
The markdown reporter leads with the verdict, the counts, and the run’s environment. Failures follow in a table, and warnings and skips follow in collapsed sections:
The default runFolder reporter writes this summary as testResults.md in the run folder, so you get one without adding the markdown reporter. The run prints the file’s path after Run summary:. Paths inside testResults.md are relative to the run folder, not to the working folder as in the preceding example.
Paths print as code rather than links, because a CI job summary can’t serve your files. Run artifacts prints only when the run has a run folder.
GitHub rejects a job summary over 1 MiB, so the summary limits its size. Each section stops at 100 rows, then says how many more there are. Each reason or name stops at 300 characters. A summary that’s still too large drops its skips, then its warnings, before it touches its failures. It then ends with a note that says so.
Find each report
Reporters that write a file name it on stderr, with its absolute path:
These lines are info-level logs, so -l warning and quieter hide them. They never reach stdout, so --json stdout holds only JSON, whichever reporters run.
junit.xml and doc-detective-summary.md have fixed names and are overwritten on each run, so a CI artifact path stays stable. The json and html names carry the run ID, so each run keeps its own file.
outputDir normally names a folder. A path that ends in .json, .html, .htm, .xml, or .md counts as a file, and reports land beside it. If the json or html reporter matches that extension, it writes to that file, and it overwrites a file that’s already there.
If Doc Detective can’t write a report, it prints an error and carries on. The exit code doesn’t change:
If the report itself can’t be built, the line reads Couldn't build the <report>: <cause>. instead, and no file is written.
Step 2: Read the terminal summary
The terminal reporter prints a summary on stdout. It groups the counts by specs, tests, contexts, and steps, lists every failure, warning, and skip, and shows the run’s environment. Then it ends with a one-line verdict:
See What every reporter lists for what each line means. When an empty input or a filter means no tests run, the verdict is No tests ran, and the CLI exits 2. An empty run therefore never looks like a green run.
Logs, warnings, and progress go to stderr, so you can pipe stdout without filtering. These flags change what you see:
Only one mode can write stdout. --plain with --json, --output -, or --dry-run exits 2 with one line on stderr, such as Error: set `--json` or `--plain`, not both. The same goes for an output of - or a dryRun of true in config.
Step 3: Find the JSON results
Every default run saves its results to .doc-detective/runs/<runId>/testResults.json. For a path that stays the same between runs, pass --output:
--output(or theoutputconfig key) names the results file, and Doc Detective overwrites it on each run.-writes the results to stdout instead. A folder exits2, so use--output-dirfor folders.- The flag beats the config key. So
--output -writes only to stdout, even when config names a file. - With
--dry-run,--outputgets the test plan, which still prints on stdout. - The
jsonreporter writestestResults-<runId>.jsoninoutputDir, named after the run’s folder. Use it when you want to keep a file per run. Leave it out when you pass--output, or you get both files.
The results carry a summary object with the pass, fail, warning, and skipped counts. The per-spec, per-test, per-context, and per-step detail follows it. For an example of the results structure, see Create your first test. To act on results programmatically, parse the file. See Fail CI when tests fail.
Rely on these fields
These parts of the results are a stable contract for scripts. A change to any of them needs a new major version:
summary.specs,summary.tests,summary.contexts, andsummary.steps, each with whole-numberpass,fail,warning, andskippedcounts.summary.stepscounts steps only, and the automatic recording isn’t a step.resulton every spec, test, context, and step, with the valuePASS,FAIL,WARNING, orSKIPPED.resultCodeon every step and automatic recording whoseresultisFAIL, and only then. It says what kind of failure it was:environment: the network, the browser session, or the page load failed.drift: a browserfindorclickmissed its element, or adragAndDropmissed its source or target, but similar ones exist, so the page probably changed.assertion: anything else, such as a missing element with nothing close, or a wrong status code.
resultHinton a failed step or automatic recording, when Doc Detective has a suggested fix. Adriftstep’s hint names the closest matches. See Troubleshoot a failing or flaky test.durationMson the run and on every spec, test, context, and step.autoRecording.resulton every context Doc Detective tried to record automatically, andautoRecording.recordingPath, relative torunDir, when it saved a video. See Where the recording shows up.runIdandrunDir, except when a filter matches nothing. That run has no run folder, andspecsis empty.- The four
--plaincolumns, in order. New columns only go at the end.
Doc Detective can add new fields at any time, so ignore the ones you don’t recognize. The report_v3 schema defines the full shape. Every results file validates against it, including a run that skipped everything or found no tests. A skipped context has an empty steps list. A run with no tests still has startedAt, environment, and durationMs. The --dry-run plan validates against the resolvedTests_v3 schema.
Steps show what ran
Each step in the results is the effective step, the one Doc Detective ran. Shorthand appears in its full form, with every default filled. A step written as {"goTo": "https://example.com"} reports goTo.url, goTo.timeout, and the rest of the goTo defaults. So read an action’s fields from the object, such as goTo.url or runShell.command. A screenshot or recording reports its file’s absolute path, so read screenshot.path or record.path to find the file. A click or find string stays a string, because a string already matches an element by any identifier. Step-level fields you didn’t set, such as variables, stay out. The expanded form is only how results report a step, so your specs can keep the shorthand.
Find slow specs with durationMs
Every node in the results carries a durationMs field in whole milliseconds. That covers the run, each spec, each test, each context, and each step. Doc Detective populates it. You never set it yourself.
The meaning shifts slightly by level, and the difference matters when you run tests concurrently:
Spec and test durations are sums of work, not elapsed spans. Contexts from every test run through the same set of concurrent runners. An elapsed span for a spec would therefore count time while unrelated specs were running. Summing keeps the number stable no matter what you set concurrentRunners to. That’s what you want when comparing specs to each other.
The consequence: when concurrentRunners is greater than 1, the run’s durationMs is less than the sum of its specs’ durations, because specs overlapped. That’s expected. Read the run value as elapsed wall-clock time, and the spec values as where the work went.
To find the specs slowing your CI down, sort the specs by durationMs:
Anything that runs more than once reports the final attempt in durationMs. That’s the attempt the reported result describes. What that costs you depends on which kind of retry happened:
- A step re-run by
onFailretry routing reports only its last attempt. The enclosing context’s duration still covers every attempt and the waits between them, so the time isn’t lost from the totals. It isn’t separable, though. The difference between a context and the sum of its steps also includes ordinary setup and cleanup. Read it as an upper limit on what retrying cost, not a measurement of it. Useattemptsto tell whether a step retried at all. - A context re-run by the
retriespolicy reports only its last attempt. No context, test, or spec duration absorbs the earlier ones. The run-leveldurationMsis wall-clock, so it does include them. Theretriescount is your signal that it happened.
A step that never ran reports 0. That covers a step that was skipped, guarded off, or downstream of a failure.
Tell environment changes from product changes
When a test that passed yesterday fails today, check whether the environment changed before you debug the product. The results record what ran each run:
environmentdescribes the machine that ran the tests: the Doc Detective and Node.js versions, the platform, the processor architecture, and the OS release. It leaves out the working directory. If Doc Detective can’t read its own version, it leaves outdocDetectiveVersion.- Each context that started a browser records the
browser.versionand thedriverthat drove it. A context without a browser has neither. Safari’s driver reports no version. startedAtis an ISO 8601 UTC timestamp with milliseconds. It’s on the run, each context, and each step that ran. A node ends atstartedAtplusdurationMs. Specs and tests have nostartedAt, because their durations are sums rather than spans.
To spot a changed browser between runs, print one line per results file with its start time and versions:
Use startedAt for the time of a run, not runId. runId names the run folder. It sorts by time, but its format can change.
Read the warm-phase timings
The results also carry a warm object that records what the run provisioned before executing tests. At the start of every run, Doc Detective front-loads setup the tests would otherwise pay one at a time. It runs those tasks concurrently. That setup covers browser and driver installs, simulator and emulator boots, and related downloads. Each entry lists the task, its outcome, and how long it took:
Outcomes are warmed (Doc Detective performed the work), skipped (nothing to do, or the environment handles it later), and failed. The warm phase is best-effort. A failed task logs a warning and never fails the run. The affected test context retries or skips with its normal behavior and reason. Use the timings to spot provisioning costs in slow CI runs. A long warmed task on every run usually means the runtime cache isn’t persisted between runs.
Step 4: Find the HTML report
The html reporter writes a self-contained HTML report you can open in a browser, as testResults-<runId>.html in outputDir. The default run folder also holds a copy, named testResults.html.
The report embeds the same results as the JSON file. A single file is therefore enough to share a run with someone who doesn’t have Doc Detective installed. Its header shows the run’s ID, start time, and duration. It also shows the Doc Detective and Node.js versions and the operating system.
The report also shows the run’s automatic screenshots and recordings. Each step’s automatic screenshot appears in its media strip, labeled Automatic, after any screenshot the step took itself. Each context’s automatic recording plays at the top of its section, labeled Automatic recording. The media work in both copies, because each file links to them from where it sits. The two copies are otherwise the same page.
The verdict at the top of the report counts tests, and each context’s label shows the browser and driver versions that ran it.
The report embeds the results, not the media. Automatic screenshots and recordings load from the run folder, so keep the report beside the .doc-detective/ folder when you move or share it. A report shared on its own shows the results without them.
Step 5: Collect the run folder and artifacts
The runFolder reporter archives each run into its own folder so you can attach it to a CI job or diff one run against another:
The file names inside the folder are constant, because the run ID lives in the folder name. Two run folders therefore compare cleanly. By default, every run captures a screenshot after each UI step and a video of each context. They land beside the results in the same folder. When a screenshot step’s path is a URL, its new screenshot goes in the context’s screenshots/ folder too. It’s named <stepId>_<timestamp>_ plus the URL’s filename. That name has a timestamp in it, so it differs between runs. The whole folder becomes a single artifact to upload from CI for reviewers to inspect.
Run folders add up: Doc Detective keeps every one and never deletes them. Keep them out of commits by adding .doc-detective/ to .gitignore, or your outputDir if you set one. Clear old ones out when you no longer need them. To stop writing screenshots and recordings, set autoScreenshot and autoRecord to false.
Step 6: Fail CI when tests fail
The exit code from the CLI gates your build, so most pipelines need nothing extra:
A WARNING result never fails a run. Neither does a SKIPPED result, unless every spec skipped, because then nothing was tested. If a suite only applies to one platform, run that job only on that platform.
If you want different behavior, you have two options:
- Report without failing. Pass
--no-exit-on-fail, or setexitOnFail: falsein your config. Failed, empty, and all-skipped runs then exit0, and invalid specs are skipped with a warning. Usage errors, invalid config, and crashes still exit2. This suits triaging an existing suite before you turn on the gate. - Apply your own logic. Read the
summaryobject from the results file and decide for yourself. This example tolerates up to two failing specs:
The && runs the check only if Doc Detective itself exited cleanly. A crash or a broken config still fails the step, and the results parse never hides it.
In a GitHub Actions workflow, the action applies these rules through its exit_on_fail input. See the GitHub Action guide.
Verify it works
After a run, confirm that:
- The terminal shows the summary you expect, and stderr names each report file.
- The results file exists at the path you passed to
--output. - The
.doc-detective/runs/<runId>/folder exists withtestResults.jsonand any screenshots or recordings from the run.
What’s next
- Run Doc Detective in CI with the GitHub Action.
- Run in Docker and headless for containerized pipelines.
- Upgrade to Doc Detective 5 if your pipeline reads results the version 4 way.
- Troubleshoot a failing or flaky test when the results aren’t green.