Monitoring Jest Tests using GitHub Actions
You can integrate your GitHub Actions pipeline workflow with Foresight to monitor the Jest test runs of your Node.js project.

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.

Starting with a Foresight Node.js workflow template

There are two types of GitHub Action to integrate your Node.js project with Thundra Agent.

Running the Command With Thundra

It is possible to run test commands by giving them to the Thundra stage like below.
1
# ...
2
3
steps:
4
- uses: actions/[email protected]
5
6
# Specify your npm / yarn install step
7
- name: Set up Node 12
8
uses: actions/setup-[email protected]
9
with:
10
node-version: '12'
11
- run: npm install
12
13
- name: Thundra Foresight JS Instrumentation
14
uses: thundra-io/thundra-foresight-js-[email protected]
15
with:
16
apikey: ${{ secrets.THUNDRA_APIKEY }}
17
project_id: ${{ secrets.THUNDRA_PROJECT_ID }}
18
19
# Modify or remove the command
20
# Default is "npm test"
21
# Modify accoding to you test script.
22
# ex: yarn run test:integration || npm run test:e2e
23
command: npm run test:all
Copied!
If you are looking for manual integration for Jest, learn more.

Running the Command Separately

If you plan to run your tests manually, you must use THUNDRA_JEST_ARGUMENT environment variable for activating Thundra.
1
# ...
2
3
steps:
4
- uses: actions/[email protected]
5
6
# Specify your npm / yarn install step
7
- name: Set up Node 12
8
uses: actions/[email protected]
9
with:
10
node-version: '12'
11
- run: npm install
12
13
- name: Thundra Foresight JS Instrumentation
14
uses: thundra-io/[email protected]
15
with:
16
apikey: ${{ secrets.THUNDRA_APIKEY }}
17
project_id: ${{ secrets.THUNDRA_PROJECT_ID }}
18
19
- name: Test Run
20
run: npm run test -- ${THUNDRA_JEST_ARGUMENTS}
Copied!
If you are looking for manual integration for Jest, learn more.

Parameters

Name
Requirement
Default
Text
apikey
Required
-
Thundra API Key
project_id
Required
-
Your project id from Thundra. Will be used to filter and classify your test runs.
framework
Optional
jest
Test framework type.
Currently only jest framework is allowed.
environment
Optional
-
You can specify Jest test environment using with jsdom or node values.
For jest which is >= 27.0.0, default test environment is node. For this reason,
Thundra will set its test environment to jest-environment-node.
For jest which is < 27.0.0, default test environment is jsdom. For this reason, Thundra will set its test environment to jest-environment-jsdom.
command
Optional
-
The Npm / Yarn command you want to run.
append_thundra_arguments
Optional
true
If value is true, Thundra will try to append required argument to your command.
If value is false, environment variable THUNDRA_JEST_ARGUMENTS must be passed to script as argument manually.
agent_version
Optional
-
A specific version Thundra Node Agent you want to use should be defined here. If this value is not specified latest version of Thundra Node Agent will be use.

Notes

Parameter Command

If the npm script to be used to start the test contains a jest command like below;
package.json
1
{
2
...
3
"scripts": {
4
"test:all": "jest"
5
}
6
}
Copied!
Thundra will pass the required argument automatically to your command.
If it doesn't contain directly jest command like below;
package.json
1
{
2
...
3
"scripts": {
4
"test:unit": "jest --runTestsByPath ./__tests__/unit/* ${THUNDRA_JEST_ARGUMENTS}"
5
"test:integration": "jest --runTestsByPath ./__tests__/integration/* ${THUNDRA_JEST_ARGUMENTS}"
6
"test:all": "npm run test:unit && npm run test:integration"
7
}
8
}
Copied!
You need to append the THUNDRA_JEST_ARGUMENT environment variable to your child scripts.
Last modified 1mo ago