Skip to content
Skills Library
Programming · Testing

flaky-tests

/flaky-tests

Diagnose and prevent flaky Biloba TypeScript/Vitest tests — redundant client-side retry loops, immediate mode, single-shot evaluate reads, optimistic UI, async layout, first-match-wins network handlers, held responses, vacuous assertions, visual update/tolerance hazards, lifecycle leakage, and timer-driven UI (debounces, countdowns, expiries) taken off real time with the page clock, including why polling never advances a paused clock. Use when a Biloba Vitest test is intermittent, order-dependent, load-sensitive, or only fails in CI/parallel workers.

Author
onsi ↗
Repository
biloba ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Diagnose and prevent flaky Biloba TypeScript/Vitest tests — redundant client-side retry loops, immediate mode, single-shot evaluate reads, optimistic UI, async layout, first-match-wins network handlers, held responses, vacuous assertions, visual update/tolerance hazards, lifecycle leakage, and timer-driven UI (debounces, countdowns, expiries) taken off real time with the page clock, including why polling never advances a paused clock. Use when a Biloba Vitest test is intermittent, order-dependent, load-sensitive, or only fails in CI/parallel workers.

Original author description

Diagnose and prevent flaky Biloba TypeScript/Vitest tests — redundant client-side retry loops, immediate mode, single-shot evaluate reads, optimistic UI, async layout, first-match-wins network handlers, held responses, vacuous assertions, visual update/tolerance hazards, lifecycle leakage, and timer-driven UI (debounces, countdowns, expiries) taken off real time with the page clock, including why polling never advances a paused clock. Use when a Biloba Vitest test is intermittent, order-dependent, load-sensitive, or only fails in CI/parallel workers.

How it works

  1. Common residual races
  2. Visual traps
Original SKILL.md headings · 35 lines, 422 words
SKILL.md preview
---
name: flaky-tests
description: Diagnose and prevent flaky Biloba TypeScript/Vitest tests — redundant client-side retry loops, immediate mode, single-shot evaluate reads, optimistic UI, async layout, first-match-wins network handlers, held responses, vacuous assertions, visual update/tolerance hazards, lifecycle leakage, and timer-driven UI (debounces, countdowns, expiries) taken off real time with the page clock, including why polling never advances a paused clock. Use when a Biloba Vitest test is intermittent, order-dependent, load-sensitive, or only fails in CI/parallel workers.
---

# Flaky Biloba Vitest tests

Biloba actions and assertions already poll inside `bilobad`. Start by deleting outer retries:

```ts
// Good: one request; the daemon owns the retry loop.
await session.getByRole("button", {name: "Save"}).click({timeoutMs: 5_000});
await session.getByTestId("status").expectText("Saved");
```

Do not wrap these calls in `expect.poll`, `waitFor`, sleeps, or a loop. Outer polling hides the useful inner failure and adds a process round trip per attempt. Avoid `{mode: "immediate"}` and `{immediate: true}` unless the test genuinely requires a single observation.

## Common residual races

- **Single-shot application reads:** `evaluate()` reads once. Poll with `expectEvaluation()` when the value must become true.
- **Gate then re-read:** use the `AssertionResult.observed` value from the successful assertion when available instead of taking a second page read.
- **Optimistic UI:** a changed DOM proves the click handler ran, not that the renderer applied the server response. Poll a lazily-written application-state marker or control response arrival with `holdResponse()`.
- **Async geometry:** existence does not imply settled layout. Use Biloba's geometry/style assertions rather than one-shot `getBoundingClientRect()` evaluation.
- **Network shadowing:** handlers are ordered and first-match-wins. Inspect `count()`, `stats()`, or `networkShadowDiagnostics()` to prove the intended handler fired; remove handlers when their scope ends.
- **Held responses:** always release in `finally`. A leaked hold makes the next failure look unrelated.
- **Lifecycle leakage:** reuse one root session but call `prepare()` before every test, and close worker browsers in `afterAll`.
- **Vacuous negatives:** anchor scopes and assert expected counts before negative collection assertions so an empty selection cannot pass accidentally.
- **Real timers:** a test that waits for the page's own `setTimeout` (a debounce, a toast that hides after 3s, a countdown, a session expiry) is slow when it works and flaky when the timer races the poll deadline. Don't widen the timeout: `installClock(t0)` before `navigate()`, `pauseAt(t0)`, then `runFor(ms)` or `fastForward(ms)` (`biloba-vitest:write-tests` §8).
- **A paused clock:** polling never advances it. A timeout ending in `This tab's page clock is paused at <t>; ...` means the page's timers never ran — call `runFor`, `fastForward`, or `resume` before the assertion.

## Visual traps

- A missing baseline must fail until a human reviews and writes it.
- Never enable screenshot update mode (`BILOBA_UPDATE_SCREENSHOTS`, `updateScreenshots`) in CI.
- Mask deterministic dynamic regions; do not widen tolerances until the assertion cannot fail.
- Treat byte-identical light/dark captures as suspicious when the test intended two schemes.

On failure, read `BilobaError.trajectory` before increasing timeouts. Flat means waiting longer will not help. Artifacts → `biloba-vitest:debug-failures`. Measuring a flake's rate, or confirming a fix → `biloba-vitest:flake-hunt`. Visual workflow → `biloba-vitest:visual-assertions`. Docs: <https://onsi.github.io/biloba/vitest.html>.

Versions

RepositoryScoreLicence
This page · onsi/biloba100MIT
ShepardVasNormandy/claude-skills100MIT

Database snapshot: 13.11.2026 · package version 56b199d0fae7 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100write-tests
    Author Biloba browser tests in TypeScript/Vitest — sessions, tabs, frames, CSS/semantic/XPath locators, polling actions and assertions, realistic input, cookies/storage, dialogs/downloads/network, time-dependent UI with the page clock (installClock + pauseAt/runFor/fastForward),…
  • 87flaky-specs
    Diagnose and prevent flaky Go/Ginkgo Biloba specs — specs that pass locally but fail in CI, fail intermittently under `-p` or load, or fail somewhere other than the line that is actually wrong. Biloba polls by default, so the headline rule is "don't reach for b.Immediate()".…
  • 90reliable-tests
    Diagnose, fix and prevent flaky tests, mostly timing, shared state and Windows differences. Use when a test passes and fails at random, fails only on one platform or in CI, when writing a test that waits, spawns a process, uses a port, a temp folder or timestamps, or when asked…
  • 90vitest-guide
    Use when writing or editing Vitest 3+ tests in TypeScript. Triggers on `.test.ts`, `.spec.ts`, `vitest.config.*` files, and prompts about test setup, mocking, HTTP assertions, CORS preflight tests, or type safety in tests, even when the user doesn't say 'Vitest'.
  • 100vitest-runner
    Execute JavaScript/TypeScript tests with Vitest, supporting coverage, watch mode, and parallel execution. Use for JS/TS test automation.
  • 100typescript-testing
    TypeScript testing patterns with Jest/Vitest including unit tests, integration tests, mocking strategies, and coverage. Use when writing TypeScript tests.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.