Detox reporter
Install @qualflare/detox in the Jest config Detox uses, then upload its qualflare-results folder and Detox artifacts with the Qualflare CLI.
Last updated
@qualflare/detox is the Qualflare reporter for Detox 20 or later: it writes each run's results, with retries, steps and the iOS or Android platform, to ./qualflare-results, and qf <identifier> collect --artifacts-dir ./artifacts uploads them with Detox's screenshots, videos and logs.
| Fact | Detail |
|---|---|
| Package | @qualflare/detox on npm |
| Works with | Detox 20 or later, Jest 29 or later, Node.js 18 or later |
| qf | qf ≥ 0.1.32 (requires qf 0.1.32 or later) for --artifacts-dir |
| License | Apache-2.0 |
| Source | Qualflare/qualflare-detox on GitHub |
| Without the reporter | --format detox with Detox's Jest JSON |
Before you begin
- The Qualflare CLI,
qf: Install the CLI. - A saved login:
qf login <identifier>with a project access token whose creator still holds the project role that uploads need Editor+ · project (requires the Editor role or higher in the project) (Authenticate with qf login). - The Identifier of the environment the results belong to (Environments).
Install
npm install --save-dev @qualflare/detoxIt brings @qualflare/jest with it.
Configure
Add the reporter to the Jest config Detox uses, usually e2e/jest.config.js, and keep Detox's own reporter.
module.exports = {
rootDir: '..',
testMatch: ['<rootDir>/e2e/**/*.test.js'],
testTimeout: 120000,
verbose: true,
reporters: ['detox/runners/jest/reporter', '@qualflare/detox/reporter'],
globalSetup: 'detox/runners/jest/globalSetup',
globalTeardown: 'detox/runners/jest/globalTeardown',
testEnvironment: 'detox/runners/jest/testEnvironment',
};| Option | Type | Default | Required | Description |
|---|---|---|---|---|
platform | string | detected | No |
|
Every other option is the Jest reporter's.
Every reporter shares the other settings: see Reporter configuration.
Set environment to the environment's Identifier: a name such as Staging fails the upload with HTTP 400 (Environment).
Run and upload
detox test --configuration ios.sim.debug --take-screenshots failing --record-videos failing
qf <identifier> collect ./qualflare-results --artifacts-dir ./artifactsScreenshots upload by default. Videos and device logs upload with --upload-artifacts video,trace.
--artifacts-dir takes the Detox artifacts root or one run inside it, and nothing is scanned without it: see Attach Detox artifacts.
Run in CI
- name: Upload results to Qualflare
if: ${{ !cancelled() }}
env:
QF_TOKEN: ${{ secrets.QF_TOKEN }}
QF_BRANCH: ${{ github.head_ref || github.ref_name }}
QF_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
npm install -g @qualflare/cli
qf login ci --force
qf ci collect ./qualflare-results --artifacts-dir ./artifactsif: ${{ !cancelled() }} uploads the results when tests fail, and QF_BRANCH and QF_COMMIT record a pull request's own branch and commit (Pull request branches). For GitLab CI/CD, Jenkins and Azure Pipelines, see Run the upload when tests fail.
Sharding and retries
Artifacts attach to the test, not to each attempt: a retried test's files all attach to the one test, with the attempt in each file name. To upload several CI jobs as one launch, see Merge sharded CI jobs into one launch.
What gets uploaded
- Statuses, durations and the history of each retried attempt.
- Steps and your own metadata.
- The platform,
iosorandroid. - Detox's screenshots, videos and device logs, matched to tests by test name.
The metadata calls are @qualflare/jest's, re-exported:
import { qualflare } from '@qualflare/detox';
it('signs in', async () => {
qualflare.label('suite', 'auth');
await qualflare.step('tap login', async () => {
await element(by.id('login')).tap();
});
});qf doesn't read the branch, commit, language or milestone from the report: set them on the upload (Branch, commit, language and milestone).
Troubleshooting
- No artifacts: pass
--artifacts-dir;./artifactsis never guessed. - Two tests with the same full name get each other's artifacts.
--artifacts-dir is not supported for <format> reports: the report isn't a Detox or Jest report.- Multi-device runs and
detox test --device-nameare untested. environment "Staging" does not exist in this project: use the environment's Identifier, or pass--environmenton the upload (Environment).- Screenshots can't be downloaded:
qfis older than 0.1.24. Upgrade qf.
Related
Appium reporter
Install @qualflare/appium for Appium suites run through WebdriverIO, add it to wdio.conf.js and upload iOS and Android results with the Qualflare CLI.
Espresso reporter
Add com.qualflare:qualflare-espresso to androidTestImplementation, register its run listener and upload the reports Gradle pulls with the Qualflare CLI.