Diagnose Expected vs. Actual Assertion Failures
Scenario
Three failing test outputs appear after porting a function. Inspect each Expected vs. Actual pair to classify the cause.
Try it yourself
Compare each assertion diff and decide what kind of bug it reveals.
| Case | Result |
|---|---|
| Expected: 3 (number) · Actual: "3" (string) | Select a choice above to see what happens. |
| Expected: false · Actual: true (input: freeSeats = 0) | Select a choice above to see what happens. |
| Expected error: INVALID_LENGTH · Actual value: 2 | Select a choice above to see what happens. |
Reveal the explanation
- Expected: 3 (number) · Actual: "3" (string)
Type mismatch. The score looks identical in text but fails strict equality.
- Expected: false · Actual: true (input: freeSeats = 0)
Boundary logic bug. Both are booleans, so the comparison operator itself is wrong.
- Expected error: INVALID_LENGTH · Actual value: 2
Missing guard bug. The function returned a number instead of rejecting mismatched lengths.
Reading both the type and value of Expected vs. Actual prevents chasing the wrong bug—for example, rewriting math logic when the only issue was returning a string.
Review first
Your turn
Classify `Expected: ["Ana", "Bo"] · Actual: ["Bo", "Ana"]` and state what kind of bug to look for.
Common mistake Seeing the same names and assuming the test is flaky instead of checking list order.
Check your work
Order mismatch bug: elements match, so check sorting or insertion order in the promoter loop.
Quick check
This browser could not save your progress. Changes last until you leave the page.