Your First Vitest Run
Running Vitest tests with Currents dashboard
Last updated
Was this helpful?
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.
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.

After creating a new organization and a project, you'll see on-screen instructions with your newly created Project ID and Record Key.
Option 1: Update the Vitest configuration file:
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.
{
...
"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.
Add the converted reports directory and the JUnit XML file to your .gitignore to avoid pushing temporary generated reports to your repository.
.currents
results.xmlVitest saves the JUnit XML report at the location configured by outputFile.junit — ./results.xml in the examples above.
Run currents convert to convert the JUnit XML report to a Currents-compatible format. Set --framework-version to the Vitest version you're running.
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.
The execution results will show on the Currents dashboard. A link to the run is printed when the upload completes.

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.
Check out the Vitest example in the JUnit XML example repository.
Last updated
Was this helpful?
Was this helpful?
npx vitest runnpx currents convert \
--input-format=junit \
--input-file=./results.xml \
--output-dir=.currents \
--framework=vitest \
--framework-version=v3.2.4npx currents upload --key=XXX --project-id=YYY