petrkindlmann/qa-skillsMIT2 files

Test Reliability

>-

Specification
Skill ID
petrkindlmann/qa-skills/test-reliability
Publisher
petrkindlmann
Repository
qa-skills
Installs
0
Files
2
License
MIT
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

petrkindlmann/qa-skills/test-reliabilityInstalls these files
  • SKILL.md
  • references/flaky-test-runbook.md

What this skill tells the agent

<objective> A retried test that still flakes will eventually fail 3-of-3 during your most critical release, and a silently auto-repaired test may now verify a different element entirely. This skill builds suites teams can trust: resilient locators, classified flakes, environment-aware healing, data healing, and observable repair with confidence scoring — every automated fix produces evidence a human can review. </objective>

Quick Route

SituationGo to
Test flakes in CI, root cause unknownFlake Classification → decision tree
Locator broke, want resilient replacementLocator Resilience
Action fails, suspect slow backend not UI bugEnvironment-Aware Healing
401/404/429 mid-test from stale dataData Healing
Want auto-repair with review gateObservable Repair Workflow
Isolate a flaky test without blocking CIQuarantine Management
Step-by-step triage of one flaky testreferences/flaky-test-runbook.md

Discovery Questions

Check .agents/qa-project-context.md first — it carries known flaky areas, selector strategy, and CI environment details. Skip any question it already answers.

  • What is your current flaky test rate? Check CI failure stats over the last 30 days. Below 2% is healthy; 2-5% needs attention; above 5% is eroding team trust.
  • Where is the pain concentrated? Locator breakage? Timing? Test data? Environment? If unknown, instrument first (see Flake Classification).
  • What is your current selector strategy? data-testid everywhere, mixed CSS and role-based, or no strategy (whatever works)? This sets the stability-score baseline.
  • How do you handle flaky tests today? Retry and hope, skip and forget, or something structured? Decides how much process you need to add.
  • What CI environment runs the tests? Same machine every time or different runners? Consistent or variable resources? Drives the environment-vs-test diagnosis.
  • What is your test data strategy? Shared database, per-test fixtures, factory seeding, or external services? Decides whether data healing applies.

Core Principles

  1. Prevention over cure. Writing a resilient test costs 1x. Investigating a flaky one costs 10x. Losing team trust in the suite costs 100x.
  1. Healing must be observable and reviewable. Every automated repair produces evidence: what broke, what was tried, what worked, the confidence score. Silent fixes erode trust as fast as silent failures.
  1. Classify before fixing. The fix for a timing issue is completely different from the fix for a data dependency. Wrong diagnosis wastes effort and can make things worse.
  1. Flaky tests are bugs. Not annoyances to tolerate. A flaky test either has a test bug (fix the test), reveals an app bug (fix the app), or exposes an environment issue (fix the environment).
  1. Track reliability as a metric, not a feeling. Measure flaky rate, mean time to heal, quarantine age, and selector stability. What gets measured gets fixed.
  1. Self-healing is a spectrum. Start with resilient locators (Level 1), add fallback strategies (Level 2), then environment-aware healing (Level 3), then confidence-scored auto-repair (Level 4). Do not jump to Level 4 before mastering Level 1.

Locator Resilience

Multi-Attribute Selectors (Beyond Fallback Chains)

A single locator strategy is a single point of failure. Multi-attribute selectors combine multiple signals for one element lookup — resilience without fallback-chain complexity.

The key insight: instead of "try A, then B, then C," use "find element matching A AND B AND C with tolerance for one signal missing."

// Multi-attribute locator: tries combinations from most specific to least
const submitBtn = await multiAttributeLocator(page, {
  testId: 'checkout-submit',              // most stable signal
  role: 'button',                          // semantic signal
  name: /place order/i,                    // accessible name
  nearText: 'Order Summary',              // visual context
});
// Internally: tries testId+role+name first, then testId alone, then role+name,
// then text, then nearText+role. Returns first visible match.
// Unlike fallback chains, it combines signals for higher confidence.

DOM Similarity / Neighbor Context Matching

When a locator fails, the element may still exist with changed attributes. Use surrounding DOM context to find it:

  1. Parent + tag + type: Find the container (by testId), then locate by tag and type within it.
  2. Preceding label: Find sibling text (label), then locate the adjacent input/button.
  3. Nearby text context: Find visible text near the target, then locate the element type in the same parent.

These are repair candidates scored by the confidence system below — not runtime fallbacks.

Selector Stability Scoring

Rate every selector on a 0-5 scale to prioritize refactoring.

ScoreStrategySurvives
5getByTestId('submit-order')CSS, text, and structural changes
4getByRole('button', { name: 'Submit' })CSS and structural changes
3getByLabel('Email')CSS changes; breaks on label rewording
2getByText('Submit Order')Breaks on any copy change
1locator('.btn-primary.submit')Breaks on CSS or structural change
0locator('//div[3]/button[1]')Breaks on any DOM change

Target: Average score of 3.5+ across the suite. Audit monthly. Prioritize fixing score-0 and score-1 selectors. Emit one score per locator to selector-stability.md (or a CI step) and report the suite average so the 3.5 target is verifiable, not asserted.

Flake Classification Framework

Every flaky test has a root cause category. Classifying correctly determines the fix.

Categories

CategorySignalRoot CauseFix Direction
TimingTimeout errors, passes on retry, worse in CIRace condition, animation, async operationWait for condition, not time
Data dependencyFails with other tests, passes aloneShared state, missing cleanupIsolate per-test, fixture cleanup
EnvironmentFails on specific runner, correlates with loadResource contention, network latencyMock externals, increase resources
Order dependencyFails with --shard or fullyParallelDepends on another test's side effectSelf-contained setup
Time sensitivityFails at specific times (midnight, month-end)Uses real clock, date boundaryMock clock, relative comparisons
Visual renderingScreenshot diff flickers, subpixel differencesFont rendering, antialiasing, animation frameIncrease threshold, mask dynamic regions
External serviceCorrelates with third-party statusReal HTTP calls in testsMock external APIs

Classification Decision Tree

Test is flaky
│
├── Does it pass when run alone?
│   ├── YES → ORDER DEPENDENCY or DATA DEPENDENCY
│   │   ├── Does another test create/modify data it needs? → ORDER DEPENDENCY
│   │   └── Does it share a database/file/cache? → DATA DEPENDENCY
│   │
│   └── NO → Not order/data dependent. Continue below.
│
├── Does it fail more often in CI than locally?
│   ├── YES → TIMING or ENVIRONMENT
│   │   ├── Timeout errors? → TIMING (CI is slower)
│   │   ├── Connection errors? → ENVIRONMENT (network latency / service)
│   │   └── Resource errors (OOM, disk)? → ENVIRONMENT (resource contention)
│   │
│   └── NO → Same rate locally and CI. Continue below.
│
├── Does it fail at specific times?
│   ├── YES → TIME SENSITIVITY
│   │   ├── Near midnight? → Date boundary issue
│   │   ├── Near month/year end? → Calendar calculation
│   │   └── Specific hour? → Timezone issue
│   │
│   └── NO → Continue below.
│
├── Does it involve screenshots or visual comparison?
│   ├── YES → VISUAL RENDERING
│   │
│   └── NO → Continue below.
│
├── Does it call external HTTP APIs?

Use this skill in a project

Open any RiverX project, search the Skills panel for petrkindlmann/qa-skills/test-reliability, and install it in one click.

Use this skill