Installation
Downloading and running Doc Detective is straightforward. You can install Doc Detective using NPX (Node.js) or Docker. Follow the instructions for your preferred method:
Choose NPX if you have Node.js installed and want Doc Detective on your machine locally. Choose Docker if you can’t install applications locally or prefer containerized environments. It also suits you if you need to avoid a Node.js install, or want to isolate Doc Detective from your system.
NPX
Docker
-
Install prerequisites:
- Node.js v24.15 or later
-
In a terminal, install Doc Detective globally:
If you’re working in a local copy of the
doc-detectiverepository, you need to runnpm ito install local dependencies.To try pre-release features, install from the
@nextdist-tag:npm i -g doc-detective@next. For stable releases, use the default command above. -
Save this file to your current directory as sample.spec.json:
sample.spec.json -
Run a test, pointing to the file you just created:
You’ve run your first test with Doc Detective. 🎉
You should see output in the terminal indicating the progress and results of the test. Results are also saved in the .doc-detective/runs/<runId>/ folder in the current directory, and this test saves a screenshot to example.png. To write the results somewhere else, pass --output <file> for the JSON results file or --output-dir <dir> for the run folder.
Runtime installation
Running npm i doc-detective installs the CLI and pre-installs heavy runtime assets. Those are browsers (Chrome, Firefox), drivers (ChromeDriver, Geckodriver), ffmpeg, and the npm packages that drive them, such as webdriverio, appium, and sharp. They land in your cache directory. This keeps your install ready to run tests without a separate step.
The pre-install runs in a child process and captures its output, so npm’s deprecation warnings from transitive dependencies won’t clutter your terminal.
Opt out of pre-installation
To skip the heavy asset pre-install, set DOC_DETECTIVE_AUTOINSTALL=0 (also accepts false, no, or off):
With this option, the CLI install stays small. Heavy assets install lazily the first time a test needs them.
Pre-install manually
If you opted out or need to reinstall, pre-install all runtime assets:
Install specific components
Install only what your tests need:
Check installation status
See what’s installed versus what the current version expects:
Each Doc Detective release pins every runtime npm package to the exact version its CI tested. install status marks a cached package at any other version, newer or older, as (outdated). You don’t need to fix it by hand. Doc Detective replaces it with the pinned version on the first run that loads it or on the next doc-detective install runtime. That includes a downgrade if the cached version is newer than the pin. The replacement needs network access and downloads only the packages that changed.
If you build a CI image or warm a shared cache, run doc-detective install runtime there after each upgrade so test jobs skip the download.
Override the cache location
The default cache location is $XDG_CACHE_HOME/doc-detective, or ~/.cache/doc-detective if XDG_CACHE_HOME isn’t set. On Windows, it’s %LOCALAPPDATA%\doc-detective. An existing ~/.doc-detective keeps being used. All of these persist across reboots. For containers, shared CI caches, or any environment where the cache belongs somewhere else, set a custom location:
You can also set cacheDir in your .doc-detective.json config file or pass --cache-dir. When you set more than one, --cache-dir wins over DOC_DETECTIVE_CACHE_DIR, which wins over cacheDir. A relative cacheDir resolves against the folder that holds the config file, and a relative --cache-dir or DOC_DETECTIVE_CACHE_DIR resolves against the current directory. Test runs and install commands follow the same order, so with the same flags, variables, and config, they use the same cache.
Auto-update
By default, Doc Detective checks the npm registry on startup and updates itself when a newer version is available. In the commands below, <version> is that newer version:
- Global installs (
npm i -g doc-detective): Runsnpm install -g doc-detective@<version>and re-executes. - npx invocations: Re-executes with
npx -y doc-detective@<version>. - Local project installs: Prints an “update available” message with the
npm i doc-detective@<version>command to run, instead of modifying yourpackage.json.
Auto-update never crosses a major version. When a new major version is out, Doc Detective tells you and leaves the upgrade to you. See Upgrade to Doc Detective 5 for what changes in version 5.
To disable auto-update, use any of these methods:
- Pass
--no-auto-updateon the CLI - Set
autoUpdate: falsein your.doc-detective.jsonconfig file - Set the
DOC_DETECTIVE_SKIP_AUTO_UPDATE=1environment variable
CI environments skip the update check automatically whenever the CI environment variable has a value.
Uninstall
To remove Doc Detective from a machine:
-
Uninstall the package:
For a project install, run
npm uninstall doc-detectivein the project instead. -
Delete the cache directory, which holds browsers, drivers, and runtime packages. It’s the first of these that applies:
- The path in
DOC_DETECTIVE_CACHE_DIR, if you set it ~/.doc-detective, if it exists$XDG_CACHE_HOME/doc-detectiveor~/.cache/doc-detectiveon macOS and Linux%LOCALAPPDATA%\doc-detectiveon Windows
If you set
cacheDirin a config file or passed--cache-dir, delete that folder too. - The path in
-
Delete your user config directory, which holds
config.jsonand the record that you saw the telemetry notice. It’s$XDG_CONFIG_HOME/doc-detectiveor~/.config/doc-detectiveon macOS and Linux, and%APPDATA%\doc-detectiveon Windows.
Your projects keep their .doc-detective.json files and .doc-detective/runs/ folders. Delete those by hand if you no longer want them.
Next steps
Next up, take a look at the concepts native to Doc Detective. You can also work through the guided walkthroughs in Test your docs, or explore how to write tests and actions.