> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/getting-started/other-frameworks/vitest/your-first-vitest-run.md).

# Your First Vitest Run

Vitest doesn't have a dedicated Currents reporter. Instead, Vitest writes a JUnit XML report using its built-in `junit` reporter, and [@currents/cmd](/resources/reporters/currents-cmd.md) converts and uploads it to Currents.

## Prerequisites

<details>

<summary>Create an Organization and a Project</summary>

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.

<img src="/files/kZ7AZ9THWF2rb1MkzV3d" alt="Creating an Organization and a Project in Currents dashboard" data-size="original">

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

</details>

<details>

<summary>Install @currents/cmd package</summary>

```bash
npm install @currents/cmd --save-dev
```

</details>

<details>

<summary>Enable the JUnit reporter</summary>

**Option 1**: Update the Vitest configuration file:

{% code title="vitest.config.js" %}

```javascript
import { defineConfig } from "vitest/config";

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

{% endcode %}

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

{% code title="package.json" %}

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

{% endcode %}

See [Vitest reporters documentation](https://vitest.dev/guide/reporters#junit-reporter) for the full list of the JUnit reporter options.

</details>

<details>

<summary>Update your .gitignore</summary>

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
```

</details>

## Your First Vitest Run

#### Step 1: Run the tests

```sh
npx vitest run
```

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](/resources/reporters/currents-cmd/currents-convert.md) to convert the JUnit XML report to a Currents-compatible format. Set `--framework-version` to the Vitest version you're running.

```sh
npx currents convert \
  --input-format=junit \
  --input-file=./results.xml \
  --output-dir=.currents \
  --framework=vitest \
  --framework-version=v3.2.4
```

#### Step 3: Upload the results

Run [currents upload](/resources/reporters/currents-cmd/currents-upload.md) to send the results to Currents dashboard.

```sh
npx currents upload --key=XXX --project-id=YYY
```

Set the [**Record Key**](/guides/record-key.md) and [**Project ID**](/dashboard/projects/project-settings.md) 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.

<figure><img src="/files/jjG3nJcJ2DzHWzbNLKOH" alt=""><figcaption><p>A link to the recorded results</p></figcaption></figure>

## 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](/getting-started/other-frameworks/vitest/ci-setup/vitest-github-actions.md) for an example.

## Example

Check out the [Vitest example](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/vitest) in the JUnit XML example repository.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.currents.dev/getting-started/other-frameworks/vitest/your-first-vitest-run.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
