Skip to content
The docs are now organized by product area. Old links still work. Report a broken link

Jest reporter

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.

Last updated

@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.

FactDetail
Package@qualflare/jest on npm
Works withJest 29 or later, Node.js 18 or later
qfqf ≥ 0.1.24 (requires qf 0.1.24 or later)
LicenseApache-2.0
SourceQualflare/qualflare-jest on GitHub
Without the reporter--format jest with Jest's JSON results

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/jest

Configure

// 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.

Set environment to the environment's Identifier: a name such as Staging fails the upload with HTTP 400 (Environment).

Run and upload

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

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

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). For GitLab CI/CD, Jenkins and Azure Pipelines, see Run the upload 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.

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:

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).

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).
  • Screenshots can't be downloaded: qf is older than 0.1.24. Upgrade qf.

Detox suites use @qualflare/detox, built on this reporter: see Mobile reporters.