Testing Node.js · Lecture 2
The route, with fakes
No server and no real database. The test passes a fake getCoupon and a plain object that records status and send. An expired coupon must become status 400. A valid coupon must put the total on the response. If the price test passes and this test fails, the bug is in the wiring.
node --test lectures/02-route/route.test.js
Code: lectures/02-route.