Jest Reporter
The @spekra/jest reporter integrates with Jest to capture test results and send them to Spekra for flaky test detection and stability tracking.
Installation
npm install @spekra/jestBasic Configuration
Add the reporter to your Jest configuration:
module.exports = {
reporters: [
'default',
['@spekra/jest', {
apiKey: process.env.SPEKRA_API_KEY,
source: 'my-unit-tests', // Required: identifies your test suite
}],
],
};
Or in TypeScript:
import type { Config } from 'jest';
const config: Config = {
reporters: [
'default',
['@spekra/jest', {
apiKey: process.env.SPEKRA_API_KEY,
source: 'my-unit-tests', // Required: identifies your test suite
}],
],
};
export default config;
How It Works
The reporter hooks into Jest's test lifecycle:
- On test result - Captures individual test outcomes
- On run complete - Batches and sends all results to Spekra
Non-Blocking Design
Like the Playwright reporter, the Jest reporter is designed to be non-intrusive:
- Results are sent asynchronously after tests complete
- Network failures don't fail your build
- Aggressive timeouts prevent hanging
Data Captured
The reporter captures:
| Field | Source | Example |
|---|---|---|
testFile | Test location | __tests__/auth.test.ts |
fullTitle | Suite + test name | Auth > login > succeeds |
suitePath | Describe hierarchy | ['Auth', 'login'] |
testName | It/test title | succeeds |
status | Test outcome | passed, failed, skipped |
durationMs | Execution time | 234 |
error | Failure message | Expected true, got false |
Git & CI Information
The reporter also captures:
- Git branch, commit SHA, and author
- CI provider and job URL
- Workflow/pipeline information
Differences from Playwright
No Built-in Retry
Jest doesn't have built-in test retries like Playwright. This affects flaky test detection:
- Playwright: Detects flaky tests within a single run via retries
- Jest: Detects flaky tests across multiple runs
Consider using jest-retry or running tests multiple times in CI for better flaky test detection.
No Projects
Jest doesn't have the concept of "projects" like Playwright. If you run Jest with different configurations (e.g., different Node versions), use separate API keys or add custom metadata.