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

Your First Vitest Run

Running Vitest tests with Currents dashboard

Vitest doesn't have a dedicated Currents reporter. Instead, Vitest writes a JUnit XML report using its built-in junit reporter, and @currents/cmd converts and uploads it to Currents.

Prerequisites

Create an Organization and a Project

After signing up for the dashboard service, you will be prompted to create a new organization and a project. You can change their names later.

Creating an Organization and a Project in Currents dashboard

After creating a new organization and a project, you'll see on-screen instructions with your newly created Project ID and Record Key.

Install @currents/cmd package
npm install @currents/cmd --save-dev
Enable the JUnit reporter

Option 1: Update the Vitest configuration file:

vitest.config.js
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    reporters: ["default", "junit"],
    outputFile: {
      junit: "./results.xml",
    },
  },
});

Option 2: Pass the reporter as an argument when executing Vitest.

package.json
{
  ...
  "scripts": {
    ...
    "test": "vitest run --reporter=default --reporter=junit --outputFile.junit=./results.xml",
  },
  ...
}

See Vitest reporters documentation for the full list of the JUnit reporter options.

Update your .gitignore

Add the converted reports directory and the JUnit XML file to your .gitignore to avoid pushing temporary generated reports to your repository.

.currents
results.xml

Your First Vitest Run

Step 1: Run the tests

Vitest saves the JUnit XML report at the location configured by outputFile.junit./results.xml in the examples above.

Step 2: Convert the results

Run currents convert to convert the JUnit XML report to a Currents-compatible format. Set --framework-version to the Vitest version you're running.

Step 3: Upload the results

Run currents upload to send the results to Currents dashboard.

Set the Record Key and Project ID obtained from Currents dashboard in the previous step.

Explore Your First Run

The execution results will show on the Currents dashboard. A link to the run is printed when the upload completes.

A link to the recorded results

Good To Know

vitest run exits with a non-zero code when tests fail, which stops a CI job before the results are converted and uploaded. Run the conversion and upload steps unconditionally — see Vitest - GitHub Actions for an example.

Example

Check out the Vitest example in the JUnit XML example repository.

Last updated

Was this helpful?