HomeChallengesRepsProblemsLeaderboardTake a challenge

The failure path

Testing the throw. And the forgotten await that makes every test pass.

Intermediate18 min on the clock4 graded checks · 100 pointsTests That Catch BugsPro
Graded by running your code against real cases.

What you build

  • Await the happy path and assert on the resolved value
  • Catch the failure and assert that it threw at all
  • Assert the error message is the one the spec promises
  • Make sure a function that always throws cannot pass

Done means

Your suite passes a correct loadUser and fails four that each break one part of the contract.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. It catches an error that was swallowed+30Testing what fails
  2. It catches a function that always throws+25Testing what fails
  3. It catches the wrong error message+20Testing what fails
  4. It catches the wrong user coming back+25Testing what fails

What it teaches

Testing what failsintermediate

Forget one await and you are asserting on a Promise rather than a value, and the test passes whatever the code does — which is why the failure path is where most untested bugs live.

The rest of Tests That Catch Bugs