Monitoring Jest Tests with Any CI Provider
Manual integration for Jest test.

Compatibility

  • Jest >= 24.8.0
    • Only jsdom (in package jest-environment-jsdom) and node (in package jest-environment-node) are supported as test environments.
    • Only jest-circus are supported as testRrunner

Prerequisites

The required parameters are the Thundra API Key and the Thundra Project ID, which can be obtained from the project settings screen.
Once you get your keys, make sure to set it as a secret.

Configuring your Project

Install NPM Packages

Install Thundra Node.js agent using:
1
npm install @thundra/core
Copied!
or,
1
npm install @thundra/[email protected]^2.13.
Copied!
Be aware that, the default test runner is jest-circus/runner for jest which has >= 27.0.0 version. If the Jest version of your project is < 27.0.0, you need to install the jest-circus package which is the same version as the Jest version.

Configure your jest.config.js

if thjest version of your project is >= 27.0.0, you need to add testEnvironment to your jest.config.js file like below;
jest.config.js
1
module.exports = {
2
...
3
testEnvironment: '@thundra/core/dist/bootstrap/foresight/jest/JestDefaultEnvironment.js'
4
// @thundra/core/dist/bootstrap/foresight/jest/JestEnvironmentNode.js
5
// @thundra/core/dist/bootstrap/foresight/jest/JestEnvironmentJsdom.js
6
// are option to. You can prefer especially when you want to use Jsdom or node environment.
7
}
Copied!
For jest which is >= 27.0.0, default test environment is node. When you use "JestDefaultEnvironment.js" as testEnvironment. Thundra will set its test environment to jest-environment-node.
if jest version of your project is < 27.0.0, you need to add testEnvironment and testRunner to your jest.config.js file like below;
jest.config.js
1
module.exports = {
2
...
3
testRunner: 'jest-circus/runner',
4
testEnvironment: '@thundra/core/dist/bootstrap/foresight/jest/JestDefaultEnvironment.js'
5
// @thundra/core/dist/bootstrap/foresight/jest/JestEnvironmentNode.js
6
// @thundra/core/dist/bootstrap/foresight/jest/JestEnvironmentJsdom.js
7
// are option to. You can prefer especially when you want to use jsdom or node environment.
8
}
Copied!
For jest which is < 27.0.0, default test environment is jsdom. When you use "JestDefaultEnvironment.js" as testEnvironment. Thundra will set its test environment to jest-environment-jsdom.

Environment Variables

You need to set THUNDRA_APIKEY and THUNDRA_AGENT_TEST_PROJECT_ID environment variables before start test run.
Name
Requirement
Description
THUNDRA_APIKEY
Required
Thundra API Key
THUNDRA_AGENT_TEST_PROJECT_ID
Required
Your project id from Thundra. Will be used to filter and classify your test runs.
THUNDRA_AGENT_TEST_RUN_ID
Optional
You can specify test run id
THUNDRA_AGENT_TEST_DISABLE
Optional
You can disable Foresight.
Last modified 1mo ago