# Jest reporter

Source: https://docs.qualflare.com/docs/reporters/jest · Last updated: 2026-10-29

Install @qualflare/jest, add it to the reporters in jest.config.js and upload the qualflare-results folder with the Qualflare CLI after each run.

`@qualflare/jest` is the Qualflare reporter for Jest 29 or later: it writes each run's results, with per-attempt retries, nested steps and attachments, to `./qualflare-results`, and `qf <identifier> collect` uploads the folder as one launch.

| Fact                 | Detail                                                                                       |
| -------------------- | -------------------------------------------------------------------------------------------- |
| Package              | [`@qualflare/jest`](https://www.npmjs.com/package/@qualflare/jest) on npm                    |
| Works with           | Jest 29 or later, Node.js 18 or later                                                        |
| qf                   | (requires qf 0.1.24 or later)                                                                |
| License              | Apache-2.0                                                                                   |
| Source               | [Qualflare/qualflare-jest](https://github.com/Qualflare/qualflare-jest) on GitHub            |
| Without the reporter | `--format jest` with [Jest's JSON results](https://docs.qualflare.com/docs/cli/formats#jest) |

## Before you begin

* The Qualflare CLI, `qf`: [Install the CLI](https://docs.qualflare.com/docs/cli/installation).
* A saved login: `qf login <identifier>` with a project access token whose creator still holds the project role that uploads need (requires the Editor role or higher in the project) ([Authenticate with qf login](https://docs.qualflare.com/docs/cli/authentication)).
* The **Identifier** of the environment the results belong to ([Environments](https://docs.qualflare.com/docs/runs/environments#identifier)).

## Install

```bash
npm install --save-dev @qualflare/jest
```

## Configure

```javascript
// jest.config.js
module.exports = {
  reporters: ['default', ['@qualflare/jest/reporter', { environment: 'staging' }]],
};
```

Or with the typed helper `qualflareReporter()` from `@qualflare/jest`.

Every reporter shares the other settings: see [Reporter configuration](https://docs.qualflare.com/docs/reporters/configuration).

Set `environment` to the environment's Identifier: a name such as `Staging` fails the upload with HTTP 400 ([Environment](https://docs.qualflare.com/docs/reporters/configuration#environment)).

## Run and upload

```bash
npx jest
qf <identifier> collect ./qualflare-results
```

## Run in CI

```yaml
- 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
```

`if: ${{ !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](https://docs.qualflare.com/docs/cli/ci-cd#pull-request-branches)). For GitLab CI/CD, Jenkins and Azure Pipelines, see [Run the upload when tests fail](https://docs.qualflare.com/docs/cli/ci-cd#run-when-tests-fail).

## Sharding and retries

Jest's own `--shard i/N` gives each test its shard index; point every shard at the same folder. See [Merge sharded CI jobs into one launch](https://docs.qualflare.com/docs/cli/sharding#merge-sharded-ci-jobs).

Jest reports how many times a test ran, but sends each failed attempt's error only with `jest.retryTimes(n, { logErrorsBeforeRetry: true })`.

## What gets uploaded

* Status, with the history of each retried attempt.
* Nested steps and attachments.
* Labels, links, tags, priority and parameters.

Captured output is per test file, not per test. A test sets its own metadata with the `qualflare` calls; a masked parameter's value is dropped before the report is written:

```javascript
const { qualflare } = require('@qualflare/jest');

test('checks out', async () => {
  qualflare.label('feature', 'checkout');
  qualflare.link('https://example.com/issue/42', { type: 'issue', name: 'QF-42' });
  qualflare.tag('smoke');
  qualflare.priority('high');

  await qualflare.step('add to cart', () => {
    qualflare.parameter('sku', 'widget');
    qualflare.parameter('token', process.env.TOKEN, { masked: true });
  });
});
```

`qf` doesn't read the branch, commit, language or milestone from the report: set them on the upload ([Branch, commit, language and milestone](https://docs.qualflare.com/docs/reporters/configuration#upload-metadata)).

## Troubleshooting

* A `qualflare.*()` call in `beforeAll`, `afterAll` or at module scope is dropped with a warning.
* `environment "Staging" does not exist in this project`: use the environment's Identifier, or pass `--environment` on the upload ([Environment](https://docs.qualflare.com/docs/reporters/configuration#environment)).
* Screenshots can't be downloaded: `qf` is older than 0.1.24. [Upgrade qf](https://docs.qualflare.com/docs/cli/installation#upgrading).

Detox suites use `@qualflare/detox`, built on this reporter: see [Mobile reporters](https://docs.qualflare.com/docs/reporters#mobile).

## Related

* **Guides:** [Reporters](https://docs.qualflare.com/docs/reporters) · [Upload results with qf collect](https://docs.qualflare.com/docs/cli/collect) · [Sharded runs and result directories](https://docs.qualflare.com/docs/cli/sharding) · [Upload screenshots, videos and traces](https://docs.qualflare.com/docs/cli/artifacts)
* **Reference:** [Reporter configuration](https://docs.qualflare.com/docs/reporters/configuration) · [Jest format](https://docs.qualflare.com/docs/cli/formats#jest)
* **More:** [Jest test reporting in Qualflare](https://qualflare.com/jest-test-reporting/)
