Night tests
One loop iteration adds one test that protects behavior that matters. The craft (frameworks,
flaky tests, end-to-end) is in test-everything; this skill is the loop around it. The loop
contract shared by every night loop is in ../night/references/loop-interface.md.
Activation
- Use when a repository has untested critical paths, a thin suite, or no tests at all.
- With no test runner, the first iteration sets up the smallest runner the stack already
implies (
node --test,pytest) and one smoke test. A new framework beyond that needs the owner, so record it as a decision instead. - Not for fixing failing tests: that is
night-bug-hunter. If the suite is red at baseline, stop and hand the failures to that loop.
Workflow
- Baseline: run the suite once and record pass, fail and skip counts (the supervisor has
them in the prompt when run by
/night). - Pick one target: the most-changed or most critical file without tests (git log, imports from entry points, money, auth, data writes). Skip what earlier iterations covered (handoff).
- Write one test (or one small group for one function) in the existing style. It reaches state through production code paths and asserts behavior, not implementation details.
- Prove it bites: break the code under test temporarily, confirm the test fails, restore
the code, and confirm it passes. Note this in
checks_run. - Run the suite. Report
NIGHT_RESULTwith the file covered and the next target.
Evaluation
- Keep: every evaluation command still passes, the passed-test count rises, the failed count does not, and no existing assertion was removed or loosened.
- Revert: any previously passing check fails, a test is skipped or deleted, or the new test is flaky (passes and fails across the supervisor's repeated runs).
- Inconclusive: the suite could not run (missing tool). Record it; do not count it as a win.
Stop conditions
- The critical paths in the risk map all have tests, or the last 3 targets were low value.
- The suite is red at baseline (hand over to
night-bug-hunter). - Two iterations in a row produced flaky tests: the problem is the harness, record it.
Examples
- Day: "run night-tests on
src/billing" adds one test per iteration while you watch, and stops when billing's branches are covered. - Night:
/night testsranks untested modules, runs up tomax_iterationsiterations, and the morning report lists each kept test with before and after pass counts.