Skip to content

Supabase

The Supabase store uses the @supabase/supabase-js client to write failures and detect patterns via PostgREST.

Free tier: 500 MB database, unlimited projects (paused after 1 week of inactivity).

Terminal window
bun add -D @flaky-tests/store-supabase
# or: npm install -D @flaky-tests/store-supabase
  1. Create a Supabase project at supabase.com

  2. Create the tables — go to the SQL editor and run:

    create table if not exists runs (
    id text primary key,
    started_at timestamptz not null,
    finished_at timestamptz,
    exit_code integer
    );
    create table if not exists failures (
    id text primary key,
    run_id text not null references runs(id),
    test_file text not null,
    test_name text not null,
    failure_kind text not null,
    error_message text,
    error_stack text,
    failed_at timestamptz not null
    );
  3. Get your project URL and anon key from Settings → API

  4. Add to your environment

    Terminal window
    SUPABASE_URL=https://abcdefghijklmnop.supabase.co
    SUPABASE_KEY=eyJhbGci...
import { SupabaseStore } from '@flaky-tests/store-supabase'
const store = new SupabaseStore({
url: process.env.SUPABASE_URL!,
key: process.env.SUPABASE_KEY!,
})
interface SupabaseStoreOptions {
/** Your Supabase project URL */
url: string
/** Your anon or service role key */
key: string
/** Prefix for `{prefix}_runs` / `{prefix}_failures` table names. Default: `flaky_test`. */
tablePrefix?: string
/** Retry tuning for read methods. Defaults: 3 attempts, 100ms base delay. */
retry?: { attempts?: number; baseMs?: number }
}

Driver errors are wrapped in StoreError with cause preserved. Read methods auto-retry transient failures (network transport errors, HTTP 5xx) with exponential backoff and jitter; writes are not retried (no idempotency key). Read methods accept an optional signal?: AbortSignal, forwarded to postgrest-js via native .abortSignal() for mid-flight cancellation.

Terminal window
FLAKY_TESTS_STORE=supabase \
SUPABASE_URL=https://... \
SUPABASE_KEY=eyJhbGci... \
bunx @flaky-tests/core

The anon key works with default RLS policies disabled. If you have RLS enabled on your tables, use the service role key instead (keep it in server-side secrets only, never expose to browsers).

Terminal window
SUPABASE_KEY=your-service-role-key # from Settings → API → service_role