Blog

Nobody Tests the Sad Path

September 6, 2026Xerat023 min read
Share
Nobody Tests the Sad Path

Walk through most feature test plans and you'll notice a pattern: extensive coverage of the happy path (fill out the form correctly, submit, see success), and a single bullet point, if any, for "handle errors gracefully." That asymmetry is backwards relative to how often each path actually gets exercised in production — the happy path runs correctly thousands of times a day without anyone thinking about it, while the error path is the one that runs during an actual incident, in front of a user who's already frustrated, and it's the one that's had the least scrutiny.

Why error states get skipped

It's not laziness — it's that triggering a real error state during manual testing is genuinely annoying. To see what your app does when an API call fails, you need the API call to actually fail, on demand, which usually means either waiting for a real outage (rare, badly timed) or doing something manual and disruptive: killing a local server mid-request, unplugging your network connection, temporarily breaking a config value and remembering to revert it. Each of those is enough friction that "I'll test it later" quietly becomes "I didn't test it."

The error states worth actually checking

A reasonably complete pass over a feature's error handling covers at least these, per API call the feature makes:

  • A 4xx client error (bad request, validation failure) — does the user see a specific, actionable message, or a generic "something went wrong"?
  • A 5xx server error — does the UI distinguish "this is on us, try again shortly" from a client-side problem, or does it show the same message either way?
  • A slow response — does a loading indicator actually appear, and does it eventually resolve into either the data or a timeout message, rather than spinning forever?
  • A malformed or unexpected response shape — if a field your code expects is missing or the wrong type, does it fail with a readable error, or crash the whole component?
  • A partial failure in a multi-call flow — if step 2 of 3 fails, is step 1's work rolled back, left dangling, or silently ignored? This one especially rarely gets manual coverage, because it requires making exactly one call in a sequence fail while the others succeed.

That last category is the one manual testing is worst at, because "make only the second of three calls fail" is close to impossible to do by hand reliably, and it's exactly the case that reveals whether your error handling was designed holistically or bolted onto each call independently.

Making these states reproducible instead of hypothetical

The fix for "annoying to trigger" is the same fix that applies to most flaky-condition testing: put a mock in the path instead of the real dependency, and configure the specific failure you want to see, on the specific call you want it on.

Concretely, that means being able to say "this one endpoint returns a 422 with this exact error body" without touching any of the other endpoints the feature also calls, and without writing a temporary code change to fake it. Conditional matching makes this precise rather than global — you can make one specific request (based on a query param, a header, or something in the body) return an error while every other call from the same test session behaves normally, which is exactly the "one call in a multi-step flow fails" scenario that's otherwise so hard to set up by hand.

Once triggering the error state is a one-line configuration change instead of a manual production-outage simulation, there's no longer much excuse for the sad path getting only a glance. The happy path already gets tested because it's easy to test. Making the error path equally easy to trigger is most of the work in making sure it gets equal attention.

X

Xerat02

Building MockBase.