agent's fix changed a shared mock - 30 unrelated tests broke on the next run
Fixes test-healing agents breaking unrelated tests by editing shared mocks or fixtures. Use when a healer's fix to one test breaks many others. Covers scoping fixes to the failing test, cloning shared fixtures before editing, and running the affected test subset before committing a heal. Not for genuinely coupled tests that need joint updates.
TL;DR
The agent edited a mock shared across the suite, so 30 unrelated tests broke. Scope every healing fix to the failing test: clone the shared fixture or mock for the test being healed instead of editing the shared one, then run the full affected subset before accepting the fix.
The symptom
agent's fix changed a shared mock - 30 unrelated tests broke on the next runSteps
1. Identify the shared surface the agent touched
Diff the agent's change: find the mock, fixture, or helper it edited and list every test that imports or uses it. Thirty broken tests means the mock is widely shared. Expected: A list of all tests depending on the edited mock.
2. Revert the shared edit
Restore the shared mock to its original state. The suite should go back to its pre-heal state (one failing test, not thirty). Expected: 29 of the 30 newly broken tests pass again.
3. Clone the fixture for the failing test
Give the failing test its own copy of the mock (a local fixture that wraps or copies the shared one) and apply the healing edit to the copy only. Expected: The target test gets the fixed behavior; no other test sees the change.
4. Run the dependency subset before accepting
Run the failing test plus every test that touches the shared mock. Accept the heal only if the whole subset is green. Expected: Target test fixed, zero regressions in the dependent set.
When to use
- A healing fix broke many unrelated tests
- The agent edited a conftest fixture, shared mock, or test helper
- Breakage fans out far beyond the test being healed
When not to use
- The tests are genuinely coupled and need the same update (then update them deliberately)
- Only the target test uses the mock (no blast radius, edit freely)
- The breakage is in production code the fix changed (different problem)
Why it happens
Healing agents optimize for the failing test in front of them. Shared mocks look like the fastest lever, but they are load-bearing for the whole suite. Editing one is a global change disguised as a local fix, so the blast radius is the entire dependent set.
Edge cases
- Deeply nested fixture chains: clone at the narrowest level that fixes the test.
- Autouse fixtures: they affect everything; never let a healer edit one without a full-suite run.
- If the shared mock is itself wrong, fix it deliberately with a full-suite run, not as a side effect of healing one test.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_xGiJqagFZy44Ax85V6pZLQ