For the complete documentation index, see llms.txt. This page is also available as Markdown.

Vitest - GitHub Actions

Running Vitest in Parallel on GitHub Actions using Matrix Workflow

TL;DR Check out the example repository:

https://github.com/currents-dev/currents-junit-xml-example

Currents uses the native Vitest sharding to split the tests between multiple containers. Each shard writes its own JUnit XML report, converts it and uploads it under a shared CI Build ID.

Here's an example workflow configuration file:

.github/workflows /vitest.yml
name: Run Vitest

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2]

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: npm install

      - name: Run tests in shard ${{ matrix.shard }}
        run: npx vitest run --shard=${{ matrix.shard }}/2 --reporter=default --reporter=junit --outputFile.junit=./results.xml

      # `vitest run` exits non-zero on test failures - report the results anyway
      - name: Convert test results to Currents format
        if: always()
        run: npx currents convert --input-format=junit --input-file=./results.xml --output-dir=.currents --framework=vitest --framework-version=v3.2.4

      - name: Upload test results to Currents.dev
        if: always()
        # CURRENTS_RECORD_KEY is a secret stored in the repository settings
        env:
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: |
          npx currents upload --project-id XXXXXX --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
  • Get your Record Key and set GH secret variableCURRENTS_RECORD_KEY.

  • Update npx currents upload --project-id argument to your project's id.

  • Set --framework-version to the Vitest version installed in the workflow.

Explore

Last updated

Was this helpful?