# Vitest reporter

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

Install @qualflare/vitest for Vitest 3 or later, add it to vitest.config.ts and upload the qualflare-results folder with the Qualflare CLI.

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

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

## 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/vitest
```

Vitest 2 and earlier aren't supported.

## Configure

```typescript
// vitest.config.ts
import { defineConfig } from 'vitest/config';
import { qualflareReporter } from '@qualflare/vitest';

export default defineConfig({
  test: {
    reporters: [['default'], qualflareReporter({ environment: 'staging' })],
  },
});
```

The tuple form works too: `['@qualflare/vitest/reporter', { environment: 'staging' }]`.

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 vitest run
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

Vitest passes its own `--shard` to the reporter, which converts it to a 0-based 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).

Vitest has no per-attempt record, so the reporter rebuilds the attempts from the error list: attempts have no duration, and a test that uses `expect.soft()` sends no attempts.

## What gets uploaded

* Status and retries.
* Assertion diffs.
* Steps and attachments.
* Labels, links, tags and priority.

Vitest has no `test.step()`: steps come only from `qualflare.step()`. A test sets its own metadata with the `qualflare` calls:

```typescript
import { test } from 'vitest';
import { qualflare } from '@qualflare/vitest';

test('a user can check out', async () => {
  qualflare.label('epic', 'Billing');
  qualflare.link('https://tracker.example/QF-42', { type: 'issue', name: 'QF-42' });
  qualflare.tag('smoke');
  qualflare.priority('high');
  await qualflare.step('add an item to the cart', () => {
    qualflare.parameter('sku', 'BOOK-1');
  });
});
```

`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

* Browser-mode screenshots and traces aren't attached.
* Only PNG, JPEG and GIF attachments upload as files; other types stay inside the report.
* `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).

## 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) · [Vitest format](https://docs.qualflare.com/docs/cli/formats#vitest)
* **More:** [Vitest test reporting in Qualflare](https://qualflare.com/vitest-test-reporting/)
