Quick Start

Get started with Flakiness Detective in under 5 minutes

Step 1: Install

pnpm add @flakiness-detective/core @flakiness-detective/adapters

Step 2: Basic Usage

Create a simple detection script:

import { FlakinessDetective } from '@flakiness-detective/core';
import { 
  createDataAdapter, 
  createEmbeddingProvider 
} from '@flakiness-detective/adapters';

// Configure adapters
const dataAdapter = createDataAdapter({ 
  type: 'in-memory' 
});

const embeddingProvider = createEmbeddingProvider({ 
  type: 'mock' 
});

// Create detective instance
const detective = new FlakinessDetective(
  dataAdapter,
  embeddingProvider,
  {
    timeWindow: { days: 7 },
    clustering: {
      epsilon: 0.15,
      minPoints: 2,
      distance: 'cosine',
    }
  }
);

// Run detection
const clusters = await detective.detect();
console.log(`Found ${clusters.length} flaky test patterns`);

Step 3: Add Test Failures

Add some test failures to analyze:

const failures = [
  {
    id: '1',
    testTitle: 'Login button should be visible',
    testFilePath: 'tests/auth.spec.ts',
    errorMessage: 'Timeout 30000ms exceeded waiting for element',
    timestamp: new Date('2025-01-10'),
    metadata: {}
  },
  // ... more failures
];

await dataAdapter.addFailures(failures);

// Now detect patterns
const clusters = await detective.detect();

Using the CLI

Or use the CLI for quick analysis:

# Detect flaky tests
flakiness-detective detect \
  --adapter=in-memory \
  --embedding=mock \
  --epsilon=0.15 \
  --days=7

# Generate report
flakiness-detective report --limit=10

Next Steps