Skip to content

Files

Latest commit

cc7581a · May 7, 2025

History

History
127 lines (80 loc) · 3.47 KB

your-first-jest-run.md

File metadata and controls

127 lines (80 loc) · 3.47 KB
description
Running Jest tests with Currents dashboard

Your First Jest Run

Setting up Currents for running and recording Jest tests in parallel can be done seamlessly within a few minutes.

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.

Select Jest from the framework selection list.

Install @currents/jest and @currents/cmd packages
npm install @currents/jest @currents/cmd --save-dev

Note: @currents/jest requires

  • Jest v29.5.0+
  • Node.js v18.20.4+
Use the Currents reporter

You have two options on how to use our reporter.

Option 1: Update Jest configuration file:

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

import type { Config } from "jest";

const config: Config = {
  reporters: ["default", "@currents/jest"], // Add this line to your config
};

export default config;

{% endcode %}

Option 2: Pass our reporter as an argument when executing Jest.

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

{
  ...
  "scripts": {
    ...
    "test": "jest --reporters=@currents/jest",
  },
  ...
}

{% endcode %}

Update your .gitignore

Add a line in your .gitignore to avoid pushing temporary generated reports to your repository.

.currents

Your First Jest Run

Upon running Jest tests, Currents reporter for jest generates a temporary folder containing the test results. To upload the results to Currents, you must run currents-upload.md

Step 1: Run the tests

npx jest --reporters=@currents/jest

Step 2: Upload the results

Run the following command to upload the last results to Currents dashboard (see currents-upload.md)

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

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

{% hint style="info" %} You can defined the Record Key and Project ID in the Reporter configuration. {% endhint %}

Explore Your First Run

The execution results will show on the Currents dashboard. The latest report should be uploaded to Currents, and a link to the run will be displayed.

A link to the recorded results

Good To Know

To provide reliable information about your tests, Currents run a "discovery" process - i.e. exploring the full test suite details. The discovery runs as part of currents upload command. Behind the scenes, the command runs jest in discovery mode.

{% hint style="info" %} It is important to ensure that

npx jest --reporters=@currents/jest and currents upload share the same environment variables {% endhint %}