Test writing discipline

From handsontable/handsontable · View interactive version

Test writing discipline is an AI agent skill from the GitHub repository handsontable/handsontable. Use when writing, fixing, or reviewing tests for any Handsontable change (unit, E2E, or wrapper), and whenever a test is red during feature work. Enforces that tests prove intended behavior – not just execute code, and never "green for the sake of green". Covers intent-first (write the test from the

How to use this skill

Skill file

Test-writing discipline

Correct behavior is the goal, not green. A test that asserts nothing, or asserts the buggy output, certifies the bug. Fix a red test by correcting the code or tightening the test. These rules apply on top of handsontable-playwright-e2e, handsontable-e2e-testing, handsontable-unit-testing.

Intent, not implementation

Write the test from the requirement (what the user or API is supposed to get), ideally before the implementation. For E2E, state the user-observable expectation before wiring a selector.

When a test is red

The code is the prime suspect. Check whether the expectation matches the intended behavior:

Banned ways of faking green

Reach green only by fixing code or tightening the test. Reject:

The Stop hook and pre-push run the test you touched and block on red; that forces reconciliation, it does not authorize weakening.

Weakening over an admitted race needs a ticket in the same PR

An assertion weakened or deleted with a race as the reason ("held 15/15 locally", "flakes on classic", "racy on develop") ships only with a filed ticket in the same PR, named beside the change. "Still open, no ticket" is a review blocker (#13332).

"Passes on retry" and "passes in isolation" are not determinism evidence

Bug fixes: failing test first

  1. Reproduce the bug as a test and watch it fail for the right reason (the missing behavior, not a typo or bad selector).
  2. Apply the fix and watch the same test pass.
  3. On a bugfix PR, name the spec that fails without the fix.

Cover what the change adds

Before saying "done"

No hollow assertions

Mocking

Broken legacy tests

The Jasmine suite is frozen. Rewrite a broken or flaky legacy *.spec.js as a Playwright test in tests/e2e/ and delete the Jasmine one (no sleep() patches). Routine, low-risk edits to an existing Jasmine spec are fine.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.