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
DocsReportersPlaywright Config

Playwright Configuration

Complete reference for all configuration options available in the @spekra/playwright reporter.

Full Example

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['html'],
    ['@spekra/playwright', {
      // Required
      apiKey: process.env.SPEKRA_API_KEY,
      
      // Optional
      apiUrl: 'https://spekra.dev/api/reports',
      enabled: process.env.CI === 'true',
      debug: false,
      timeout: 30000,
      batchSize: 100,
      redact: ['my-secret', /password/i],
    }],
  ],
});

Options Reference

apiKey
string
required

Your Spekra API key. Get one from Settings → API Keys.

We recommend using an environment variable rather than hardcoding the key.

apiUrl
string
optional
Default: https://spekra.dev/api/reports

The Spekra API endpoint. Only change this if you're using a self-hosted instance.

enabled
boolean
optional
Default: true

Whether to send results to Spekra. Set to false to disable reporting.

Common pattern: enabled: process.env.CI === 'true' to only report in CI.

debug
boolean
optional
Default: false

Enable verbose logging. Useful for troubleshooting configuration issues.

Logs are written to stderr and include:

  • Configuration values (redacted)
  • Number of results captured
  • API response status
timeout
number
optional
Default: 30000

Timeout in milliseconds for the API request. If exceeded, the request is abandoned silently.

batchSize
number
optional
Default: 100

Maximum number of results to send in a single request. Large test suites are automatically split into batches.

redact
boolean | (string | RegExp)[] | RedactionOptions
optional
Default: true

PII/secrets redaction. Enabled by default with built-in patterns for emails, tokens, API keys, etc.

  • true (default): Enable with built-in patterns
  • false: Disable redaction (not recommended)
  • ['pattern', /regex/]: Add custom patterns to built-in
  • { enabled, patterns, replaceBuiltIn }: Full control

Environment Variables

The reporter also respects these environment variables:

VariableDescription
SPEKRA_API_KEYAPI key (can be used instead of config)
SPEKRA_ENABLEDSet to false to disable reporting
SPEKRA_DEBUGSet to true for verbose logging

Config options take precedence over environment variables.

CI-Only Reporting

A common pattern is to only report results when running in CI:

['@spekra/playwright', {
  apiKey: process.env.SPEKRA_API_KEY,
  enabled: !!process.env.CI,
}]

Multiple Environments

If you use different Spekra organizations for different environments:

const isProduction = process.env.ENVIRONMENT === 'production';

['@spekra/playwright', {
  apiKey: isProduction 
    ? process.env.SPEKRA_PROD_API_KEY 
    : process.env.SPEKRA_DEV_API_KEY,
}]

Redacting Sensitive Data

Redaction is enabled by default with built-in patterns for common PII/secrets (emails, tokens, API keys, etc.). To add custom patterns:

['@spekra/playwright', {
  apiKey: process.env.SPEKRA_API_KEY,
  redact: [
    'my-internal-secret',
    /custom-token-\w+/gi,
  ],
}]

For full control over redaction:

['@spekra/playwright', {
  apiKey: process.env.SPEKRA_API_KEY,
  redact: {
    enabled: true,
    patterns: ['custom-secret', /internal-\w+/],
    replaceBuiltIn: false,  // Set true to only use your patterns
  },
}]

Matched patterns are replaced with [REDACTED] before sending to Spekra. See Security → Data Handling for the full list of built-in patterns.

Troubleshooting

Results Not Appearing

  1. Check that enabled is true
  2. Verify your API key is correct
  3. Enable debug: true to see what's being sent
  4. Check network connectivity to spekra.dev

Slow Test Completion

The reporter sends results after all tests complete. If this takes too long:

  1. Reduce timeout to fail faster on network issues
  2. Check your network connectivity
  3. Ensure you're not behind a firewall blocking the API

Partial Results

If only some results appear:

  1. Check for errors in the debug output
  2. Verify batchSize isn't too small
  3. Look for timeout errors in logs

Previous

Playwright

Next

Jest