Skip to main content

Jest Integration

Run your Jest tests as usual and have results automatically reported to ProvaLab.io. Works with React, Node.js, and any Jest-based testing setup.

Install

npm install tms-node-sdk

Requirements: Node.js >= 18.0.0, Jest >= 27.0.0

Configure

1. Set environment variables

export TMS_API_KEY=your-api-key
export TMS_API_URL=https://tms.yourcompany.com
export TMS_ORGANIZATION_ID=1
export TMS_PROJECT_ID=12

2. Add the ProvaLab.io reporter to your Jest config

jest.config.js
module.exports = {
reporters: [
'default', // Keep the default console output
'tms-node-sdk/jest/reporter', // Add ProvaLab.io reporting
],
};

With custom options:

jest.config.js
module.exports = {
reporters: [
'default',
['tms-node-sdk/jest/reporter', {
runName: 'Unit Tests - API', // Custom name for this test run
}],
],
};

Using package.json instead:

package.json
{
"jest": {
"reporters": [
"default",
"tms-node-sdk/jest/reporter"
]
}
}

Run

npx jest

You'll see ProvaLab.io output after Jest's normal output:

========================================
ProvaLab.io Jest Integration
========================================
Test Run ID: 848
Project ID: 12
Organization ID: 1
========================================

[PASS] Auth > should login with valid credentials (0.12s)
[PASS] Auth > should reject invalid password (0.08s)
[FAIL] Auth > should handle expired token (0.15s)
[SKIP] Auth > should support SSO login (0.00s)

========================================
ProvaLab.io Test Run Summary
========================================
Test Run ID: 848
Total: 4
Passed: 2
Failed: 1
Skipped: 1
Status: FAILED
========================================

View Results in ProvaLab.io

  1. Open ProvaLab.io and go to your project
  2. Click Test Runs in the sidebar
  3. Find the run named "Jest: 2026-02-20 14:30:00" (or your custom name)
  4. Click into it to see individual results with error details

Option 1: Include the ID in the test title

describe('Authentication', () => {
test('[TMS-201] should login with valid credentials', () => {
// your test code
expect(login('[email protected]', 'pass123')).toBeTruthy();
});

test('[TMS-202] should reject invalid password', () => {
expect(() => login('[email protected]', 'wrong')).toThrow();
});
});

Option 2: Use a mapping file

test-case-mapping.json
{
"Authentication > should login with valid credentials": { "id": 201, "priority": "critical" },
"Authentication > should reject invalid password": { "id": 202, "priority": "high" }
}
export TMS_MAPPING_FILE=test-case-mapping.json
Mapping nested describes

Jest maps test names as Describe > Nested Describe > test name. Use the full path in your mapping file to match correctly.

Advanced Configuration

Custom test run name

export TMS_TEST_RUN_NAME="API Unit Tests - PR #456"

Environment tagging

export TMS_ENVIRONMENT=staging

Log batching

The reporter batches log entries to minimize API calls:

export TMS_LOG_BATCH_SIZE=50         # Send logs in batches of 50 (default)
export TMS_LOG_BATCH_INTERVAL_MS=5000 # Or every 5 seconds, whichever comes first

Disable ProvaLab.io for local development

export TMS_DISABLED=true
npx jest

Use with Create React App

CRA uses Jest under the hood. Add ProvaLab.io reporting in package.json:

package.json
{
"jest": {
"reporters": [
"default",
"tms-node-sdk/jest/reporter"
]
}
}

Then run:

TMS_API_KEY=your-key TMS_ORGANIZATION_ID=1 TMS_PROJECT_ID=12 \
TMS_API_URL=https://tms.yourcompany.com \
npx react-scripts test --watchAll=false

Verify It Works

  1. Set your environment variables
  2. Create a simple test:
__tests__/tms-verify.test.js
test('[TMS-1] verify TMS integration', () => {
expect(1 + 1).toBe(2);
});
  1. Run it:
npx jest __tests__/tms-verify.test.js
  1. Check the console output for the ProvaLab.io banner with a Test Run ID
  2. Open ProvaLab.io and confirm the test run appears under your project
Common issues
  • "Not configured" message: Make sure TMS_API_KEY, TMS_ORGANIZATION_ID, and TMS_PROJECT_ID are all set
  • Reporter not loading: If using jest.config.ts (TypeScript), make sure ts-jest or a similar transformer is configured
  • Results not appearing: Check that TMS_API_URL points to your ProvaLab.io instance