Curriculum

Curriculum

Spot When a Diff Weakens a Test Instead of Fixing the Bug

Scenario

Inspect three diffs that all report "All tests passed".

Selected choicePick a choice below
Result—
Suspicious Diff (Test Weakening)
--- a/booking.test.js
+++ b/booking.test.js
- assert.equal(canBook(0), false);
+ assert.equal(canBook(0), true); // updated expectation

Try it yourself

Choose each diff and spot which ones cheated by weakening the tests.

Reveal the explanation
  1. Diff changes assert.equal(canBook(0), false) -> true

    Test weakening! The bug (overbooking at 0 seats) is now locked in by a corrupted test.

  2. Diff marks the failing boundary test as test.skip(...)

    Test weakening! Skipping a failing check hides the regression.

  3. 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

Which diff change is a red flag for silent test weakening?
Show the answer and reasoning

Correct answer Changing a failing assertion’s expected value to match the buggy output

Altering a valid test expectation to fit broken code hides bugs instead of fixing them.