Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

flake-pattern-reference

БесплатноБез исполняемых скриптовНе проверен

Use when a test fails only some of the time and a re-run goes green: only in CI and never on a laptop, only at night or in another time zone, only when test…

testlandот testland★ 18 звёзд на GitHub

Об этом скилле

flake-pattern-reference

Terminology note: "flaky test" is a practitioner-emergent term popularized by the Google Testing Blog (google-causes, google-flaky); ISTQB does not maintain a canonical entry. This catalog reflects industry-engineering consensus, not ISTQB authority.

A flake is rarely random - it almost always falls into one of eight recurring patterns. Identifying the pattern early shrinks the bisect search space dramatically. This catalog is a reference, not a workflow; the matching workflow is in flaky-test-quarantine.

The Google Testing Blog observed a near-linear correlation between test size and flakiness rate across ~4.2M tests (google-causes) - larger tests touch more of the eight patterns at once.

Pattern 1: async / timing

The most common flake category in UI and integration tests.

Signal What's happening
Fails ~5 - 20% of runs; passes when the machine is faster Test waits for an arbitrary setTimeout(N) instead of a deterministic event.
Fails on CI but never locally CI runners have different cold-start timings than dev laptops.
Fails after a dependency upgrade with no test code change Library's internal timing changed (e.g. Playwright auto-wait window).

Remediation:

  • Replace fixed sleeps with deterministic waits - await expect(loc).toBeVisible(), page.waitForLoadState('networkidle'), page.waitForFunction(...), etc.
  • For animations, disable them in test setup (animations: 'disabled' in Playwright; Cypress.config('animationDistanceThreshold', 0) in Cypress).
  • For absolute clock dependencies, freeze time with sinon.useFakeTimers() / vi.useFakeTimers() / Playwright's page.clock.install().

Pattern 2: test ordering

Tests pass alone, fail when run with siblings.

Signal What's happening
npm test -- --testNamePattern='^X$' passes; full run fails Test relies on state from a previously-run test.
Adding a new test breaks an unrelated existing one Implicit ordering dependency exposed by the new test pushing the old test into a different position.
Random-order test runners (Jest randomize) flag the suite Suite is order-dependent.

Remediation:

  • Run the suite with explicit randomization in CI to surface ordering deps early (jest --randomize, pytest --random-order, mocha --sort reverse).
  • Move ANY shared setup into beforeEach / afterEach, never rely on beforeAll for state that the test mutates.
  • Database tests: roll back transactions after each test instead of truncating between describe blocks.

Pattern 3: shared parallel state

Tests pass sequentially, fail when run in parallel workers.

Signal What's happening
Fails ~50% of runs in CI matrix; passes locally with -j 1 Two workers writing to the same DB row / file / port.
Fails more often as worker count goes up Linear shared-state contention.
Error message mentions "duplicate key" / "address in use" / "file already exists" Direct collision evidence.

Remediation:

  • Find the shared state two workers collide on - DB rows, files, ports, or global module state.
  • Per-worker isolation: per-worker DB schemas (PG_SCHEMA=test_${WORKER}), per-worker temp dirs (TMPDIR=/tmp/test-${WORKER}), per-worker port ranges.
  • For unique IDs: use UUIDs or a per-worker namespace prefix, not auto-increment integers shared across workers.

Pattern 4: resource leaks

Tests pass on a fresh machine, fail after the test process has run for hours.

Signal What's happening
Fails increasingly often as suite duration grows Memory or file-descriptor lea
Полный SKILL.md на GitHub

Установить flake-pattern-reference в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

.tessl-plugin/plugin.jsonevals/api-test-port-collision/criteria.jsonevals/api-test-port-collision/task.mdevals/archive-write-race/criteria.jsonevals/archive-write-race/task.mdevals/due-date-boundary/criteria.jsonevals/due-date-boundary/task.mdevals/import-job-fixed-wait/criteria.jsonevals/import-job-fixed-wait/task.mdevals/inventory-fixture-collision/criteria.jsonevals/inventory-fixture-collision/task.mdevals/leaked-clock-stub/criteria.jsonevals/leaked-clock-stub/task.mdevals/profile-completion-order/criteria.jsonevals/profile-completion-order/task.mdevals/repository-pool-exhaustion/criteria.jsonevals/repository-pool-exhaustion/task.mdevals/session-precondition-dependency/criteria.jsonevals/session-precondition-dependency/task.mdevals/shared-cart-fixture/criteria.jsonevals/shared-cart-fixture/task.mdreferences/environment-and-randomness-fixes.mdreferences/network-and-locator-fixes.mdreferences/timing-and-isolation-fixes.md

FAQ

Что делает скилл flake-pattern-reference?

Use when a test fails only some of the time and a re-run goes green: only in CI and never on a laptop, only at night or in another time zone, only when test files run in parallel (EADDRINUSE, duplicate keys, counts a little short), or about once a week with no local repro. Matches the failure to one of eight flake patterns (async timing, test order, shared parallel state, resource leaks, network, locator drift, environment variance, randomness) and gives the code fix for each, such as framework auto-waits instead of sleeps, per-worker DB schemas via workerIndex, try/finally teardown, mocked network and clock, TZ pinning and RNG seeding. Not for quarantine policy (flaky-test-quarantine) or classifying a red CI run (ci-failure-triage).

Как установить скилл flake-pattern-reference?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл flake-pattern-reference запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить flake-pattern-reference с