Spot When a Diff Weakens a Test Instead of Fixing the Bug
Scenario
Inspect three diffs that all report "All tests passed".
--- a/booking.test.js
+++ b/booking.test.js
- assert.equal(canBook(0), false);
+ assert.equal(canBook(0), true); // updated expectationTry it yourself
Choose each diff and spot which ones cheated by weakening the tests.
| Case | Result |
|---|---|
| Diff changes assert.equal(canBook(0), false) -> true | Select a choice above to see what happens. |
| Diff marks the failing boundary test as test.skip(...) | Select a choice above to see what happens. |
| Diff leaves canBook(0) === false intact and fixes freeSeats >= 0 -> freeSeats > 0 | Select a choice above to see what happens. |
Reveal the explanation
- Diff changes assert.equal(canBook(0), false) -> true
Test weakening! The bug (overbooking at 0 seats) is now locked in by a corrupted test.
- Diff marks the failing boundary test as test.skip(...)
Test weakening! Skipping a failing check hides the regression.
- Diff leaves canBook(0) === false intact and fixes freeSeats >= 0 -> freeSeats > 0
Genuine fix. The contract check stayed strict and the implementation was corrected.
Always read test file hunks in a diff first. Never approve a diff that deletes, skips, or loosens a valid contract assertion.
Review first
Your turn
Spot what is wrong in a diff that deletes assert.throws(() => canBook(-1)) to make tests pass.
Common mistake Trusting the green "4/4 passed" summary without noticing 1 test was deleted (was 5/5).
Check your work
Reject the diff; restore the invalid-input test and fix the missing freeSeats < 0 guard in production code.
Quick check
This browser could not save your progress. Changes last until you leave the page.