> 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/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-jest.md).

# @currents/jest

Currents reporter for Jest

Currents reporter for [Jest](https://jestjs.io/) generates test results that for uploading to Currents.&#x20;

The reporter stores the generated results in a temporary directory. Upload the generated results using a separate package [@currents/cmd](/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-cmd.md).

### Setup

```sh
npm install @currents/jest @currents/cmd --save-dev
```

Add the reporter to Jest configuration:

```ts
import type { Config } from "jest";

const config: Config = {
  reporters: ["default", "@currents/jest"],
};

export default config;
```

or set the `--reporters` option when running the `jest`

```sh
npx jest --reporters=@currents/jest
```

The reporter saves the test results in a temporary folder named  `.currents-report-[timestamp]-[uuidv4()]`.&#x20;

{% hint style="info" %}
We recommend adding`.currents-report*` to `.gitignore`
{% endhint %}

### Usage

* Configure the reporter
* Run the tests  `npx jest`
* Use `currents` from [@currents/cmd](/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-cmd.md)package to upload the results

Example:

{% code overflow="wrap" fullWidth="false" %}

```bash
$ npx jest --reporters=@currents/jest --reporters=default
[currents]: Run started
[currents]: Report directory is set to - /Users/agoldis/immer/.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d
# ....
[currents]: [__tests__/base.js] - spec results written to file: /Users/agoldis/immer/.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d/instances/Aql-q2CM.json
[currents]: Run completed

# 📖 see @currents/cmd documentation
$ npx currents upload --key=XXX --project-id=C3lBM6
Currents config: {
  projectId: 'C3lBM6',
  recordKey: '*****',
  removeTitleTags: false,
  disableTitleTags: false,
  debug: false
}
Report directory: '.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d'
[root] Run created: 'https://app.currents.dev/run/8466c149d9bbf745'
Script execution finished
✨  Done in 17.96s.
```

{% endcode %}

### Configuration

| Property    | Type     | Description            | Environment variable  | Default                                 |
| ----------- | -------- | ---------------------- | --------------------- | --------------------------------------- |
| `reportDir` | `string` | Test results directory | `CURRENTS_REPORT_DIR` | `.currents-report-[timestamp]-[uuidv4]` |

### Troubleshooting

Set `DEBUG=currents*` before running `jest` to obtain detailed information about the reporter execution process.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.currents.dev/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-jest.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
