Skip to content

Support merging reports for non-sharded multi-environment runs #9954

@hi-ogawa

Description

@hi-ogawa

Clear and concise description of the problem

Draft plan with Claude

As a developer using Vitest in CI with a matrix strategy (e.g., linux/macos/windows, or node 20/22), I want to merge test reports from multiple platform runs into a single report, so that I can get a unified view of test results across all environments.

Currently --merge-reports only supports merging sharded runs — where test files are split across shards with no overlap. When the same tests are run on multiple platforms (a common CI pattern), merging those blob reports produces duplicate unlabeled entries with no way to tell which result came from which platform.

Playwright supports this via their merge-reports + tag config, and it's a frequently needed workflow.

Suggested solution

Note

Reworked solution is in #9967

Use explicit tags to distinguish blobs from different environments. The blob reporter would accept a tag option that gets stored in the blob metadata and injected into each test's tags array during merge. This builds on Vitest's existing tag infrastructure (filtering, reporter display).

Blob reporter config:

// vitest.config.ts
export default defineConfig({
  test: {
    reporter: [['blob', {
      tag: process.env.CI_PLATFORM, // e.g., "linux", "windows", "node-22"
    }]],
  },
})

Merge behavior:

  • Each blob carries its tag in metadata
  • On merge, the tag is prepended to every test's tags array (e.g., ["linux", ...])
  • Same test file from different blobs becomes distinct entries, each labeled by platform
  • Reporters already understand tags, so results are immediately distinguishable

Example CI workflow:

jobs:
  test:
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - run: vitest run --reporter=blob
        env:
          CI_PLATFORM: ${{ matrix.os }}
      - uses: actions/upload-artifact@v4
        with:
          name: blob-${{ matrix.os }}
          path: .vitest-reports/

  merge:
    needs: test
    steps:
      - uses: actions/download-artifact@v4
        with:
          path: .vitest-reports/
          merge-multiple: true
      - run: vitest --merge-reports --reporter=default --reporter=json

Alternative

  • Auto-detect platform (process.platform, process.arch) and inject as tags without explicit config. Simpler for users but less flexible — doesn't cover non-OS dimensions like Node version or custom environments.
  • Playwright's approach: automatic ID deconfliction (salt duplicate IDs) + separate explicit tag config for labeling. We could start with the simpler combined approach (tag = deconflict + label) and add automatic deconfliction later if needed.

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: reportersIssues and PRs related to Vitest reporters

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions