Testing Node.js · Lecture 1

The price function

The route could not be unit tested because the database, the clock, and the response were sealed inside it. priceWithCoupon takes a subtotal, a coupon, and a time. Ten percent off 100 is 90. An expired coupon is rejected.

node --test lectures/01-price/pricing.test.js

Code: pricing.js and pricing.test.js.

Watch on YouTube