Ensure your tests are mutation-effective: they must fail when the implementation changes in ways that break intended behavior. Avoid vacuous assertions, and don’t confuse “a test exists” with “the test would catch the real bug.”
Practical standards: 1) Pin the observable contract, not a computed tautology
expect(extract(a)).toBe(extract(b)) where both sides compute the same fallback that returns undefined/empty on many mutations, the test may stay green even when behavior is broken.2) Cover the actual branch that enforces safety
3) Add boundary and shape variants where logic branches
ApiError-shaped quota errors vs plain strings).4) Use an “equivalent mutant” check before escalating severity
Example: avoid a vacuous “either/or” success assertion
// Wrong pattern (can pass on silent tool failure):
expect(toolCall || updated).toBe(true);
// Mutation-effective pattern:
if (toolCall) {
expect(updated, 'file must update when tool was called').toBe(true);
}
expect(toolCall || updated, 'must succeed via tool-call or correct content').toBe(true);
Example: test exact boundaries
// Instead of only “over limit” and “under limit”, also test equality.
expect(validateReason('x'.repeat(8000))).toBe(true);
expect(validateReason('x'.repeat(8001))).toBe(false);
Example: test alternate error shapes
it('treats ApiError-shaped quota exhaustion as exhausted', () => {
const err = { error: { code: 429, message: 'quota exhausted', status: 'RESOURCE_EXHAUSTED' } };
expect(isQuotaExhaustedError(err)).toBe(true);
});
Adopt this as a review checklist for the Testing category: