Spekra
Docs

Getting Started

  • Overview
  • Playwright
  • Jest
  • Vitest

Core Concepts

  • Flaky Tests
  • Stability Metrics
  • Test Identity

Reporters

  • Playwright
  • Playwright Config
  • Jest
  • Jest Config
  • Vitest
  • Vitest Config

Platform

  • Dashboard
  • Flaky Tests View
  • Test Runs
  • API Keys
  • Rate Limits

CI/CD

  • Overview
  • GitHub Actions
  • GitLab CI

Security

  • Overview
  • Data Handling
  • Compliance

Troubleshooting

  • Overview
  • Connection Issues
  • Missing Data
DocsReportersJest

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/jest

Basic 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:

  1. On test result - Captures individual test outcomes
  2. 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:

FieldSourceExample
testFileTest location__tests__/auth.test.ts
fullTitleSuite + test nameAuth > login > succeeds
suitePathDescribe hierarchy['Auth', 'login']
testNameIt/test titlesucceeds
statusTest outcomepassed, failed, skipped
durationMsExecution time234
errorFailure messageExpected 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.

Quick Links

Configuration Options

All available reporter options and their defaults.

Quick Start

Get up and running with Jest in 5 minutes.

Previous

Playwright Config

Next

Jest Config