skip to content

What do Detox's --record-logs, --take-screenshots and --record-videos flags produce, and what does their failing value mean?

level: juniorimportance: should knowfreq 35%

answer

  1. logs, png, mp4
  2. off by default, screenshots manual
  3. failing keeps failed tests only
  4. default root ./artifacts
  5. trailing slash skips sub-folder

basics

~20 s

They record device logs, before-and-after screenshots and screen videos for each test. Logs and videos default to none and screenshots to manual; the value failing records them but keeps files only for tests that failed, which suits CI uploads.

solid answer

~30 s

`--record-logs` saves `.log` files from the device and app, `--take-screenshots` saves `.png` screenshots before and after each test, and `--record-videos` saves an `.mp4` per test. Logs and videos default to `none`, screenshots to `manual`, which means only your own `device.takeScreenshot()` calls produce files. `all` keeps artifacts for every test; `failing` records them but keeps only the failed tests' files, so a CI upload is small and relevant. Files go under `./artifacts` by default; without a trailing slash on `--artifacts-location` Detox adds a configuration-and-timestamp sub-folder. The same settings can live in the `artifacts` section of `.detoxrc.js`, with CLI flags taking priority.

code

bash · 5 lines
bash
detox test -c android.emu.release \
  --record-logs failing \
  --take-screenshots failing \
  --record-videos failing \
  --artifacts-location artifacts/

go deeper

for a junior

Recall the three flags, what each produces, and that failing keeps files only for failed tests.

for a middle

Explain the defaults, the preset-to-plugin mapping, the artifacts root and the trailing-slash rule.

for a senior

Choose artifact settings per environment, read them in the right order during diagnosis, and handle CI limits like video on machines without acceleration.

for a principal

Balance the evidence a team keeps from every run against storage, upload time and retention.

## Artifacts: what Detox can keep from a run **Detox** artifacts are recordings from a test run: device logs, screenshots, screen recordings and a few iOS-only diagnostics. They are **off by default** — apart from screenshots you take yourself — and each kind is switched on with a `detox test` flag or the `artifacts` section of `.detoxrc.js`. | Flag | Values | Default | Produces | |---|---|---|---| | `--record-logs` | `failing`, `all`, `none` | `none` | `.log` files from the device and app | | `--take-screenshots` | `manual`, `failing`, `all`, `none` | `manual` | `.png` before and after each test | | `--record-videos` | `failing`, `all`, `none` | `none` | `.mp4` recording of each test | | `--capture-view-hierarchy` | `enabled`, `disabled` | `disabled` | iOS-only `.uihierarchy` snapshots on view action failures | | `--record-performance` | `all`, `none` | `none` | iOS-only performance recordings | ## What `failing`, `all`, `manual` and `none` mean The CLI values are presets for the plugin objects in the config file: - **`none`** — the plugin is disabled. - **`all`** — enabled for every test. - **`failing`** — enabled, but artifacts are kept **only for tests that failed** (`keepOnlyFailedTestsArtifacts: true`). - **`manual`** — enabled, but no automatic snapshots; only calls such as `device.takeScreenshot('booking-summary')` produce files. This is why `--take-screenshots` defaults to `manual`: your explicit screenshots work without any flag. `failing` is the usual CI choice: recordings happen for every test, but only the failures' files survive, so the upload stays small and every file is relevant. ## Where the files go The root is `./artifacts` by default and can be changed with `--artifacts-location` or `artifacts.rootDir`. Without a trailing slash, Detox adds a sub-folder named after the configuration and a timestamp, such as `artifacts/android.emu.release.2026-06-12 09:41:07Z/`, so repeated local runs do not overwrite each other. With a trailing slash (`artifacts/`), files go straight into the folder — convenient for a CI job that uploads a fixed path. Inside, each test gets its own folder named after its full name and prefixed with ✓ or ✗ for its result, and a custom `pathBuilder` module can change the layout. ## Setting it in the config instead of flags ```js module.exports = { artifacts: { rootDir: 'artifacts/', plugins: { log: 'failing', screenshot: 'failing', video: 'failing', }, }, // devices, apps, configurations ... }; ``` The string presets match the CLI values, a configuration can override the global `artifacts` section (or set `artifacts: false` to disable them for that configuration), and CLI flags win over the file. ## Manual screenshots and how the flag treats them `device.takeScreenshot('booking summary')` returns the path of a temporary `.png` immediately and schedules the file for the artifacts folder when the test ends. What happens next depends on `--take-screenshots`: - **`manual` or `all`** — the file is kept, under the test's `✓` or `✗` folder. - **`failing`** — kept only if the test failed. - **`none`** — the screenshot is taken, but not kept as an artifact. Element-level screenshots (`element(...).takeScreenshot(name)`) follow the same rules. The returned path is valid only during the test, so copy it if you compare images yourself. ## Reading them for the hotel-booking suite 1. **Video first** for a UI failure: a spinner that never ends, a system dialog over the "Book" button, the keyboard covering it. 2. **Screenshots** for a quick before-and-after comparison, especially across iOS and Android runs. 3. **Logs** for crashes, JavaScript errors and failed network calls behind a screen that never loads. ## Limits worth knowing - On iOS CI machines without hardware graphics acceleration, video recording fails with an error that it requires Metal; enable acceleration or turn videos off for that job. - Videos and `all` logs are large; `all` on a long suite can fill a runner's disk and slow uploads. - After a `Ctrl+C` locally, some temporary recording files may be left on the device or host; the docs list this as a known issue. A junior answer names the three flags and `failing`; a stronger one adds the defaults, the trailing-slash rule and why `failing` is the CI setting.

  • Why does --take-screenshots default to manual rather than none?
    `manual` enables the screenshot plugin without automatic before-and-after shots, so explicit `device.takeScreenshot('name')` calls are saved to the artifacts folder. With `none` the call still takes the image and returns a temporary path, but the file is not kept as an artifact after the test.
  • Where do flags and the config file's artifacts section conflict, which wins?
    CLI flags have the highest priority and override their counterparts in `.detoxrc.js`. Within the file, a configuration's own `artifacts` section overrides the global one, which lets a CI configuration record more than the local one without changing the command.

saying these in an interview costs you the question

  • Detox records videos of every test by default.
  • failing only starts recording after a test fails.
  • --take-screenshots none still saves device.takeScreenshot() calls.
  • The config file always overrides command-line flags.
  • Video recording works on every CI machine.