-code With Mosh- Mastering Javascript Unit Testing -
He wrote his first failing test:
function applyDiscount(user, total) { if (user.type === 'VIP') return total * 0.8; return total; } -Code With Mosh- Mastering JavaScript Unit Testing
"Thirty bucks."
He typed:
Last Tuesday was the breaking point. A simple pull request to update a discount function caused a catastrophic cascade. The login failed. The cart emptied. The CEO’s test account showed a total price of . The company had to pay customers to buy things. -Code With Mosh- Mastering JavaScript Unit Testing
And that made him a real engineer.
Mosh drew a diagram. "Don't test the database. Test your logic. Replace the real dependency with a mock." Leo learned to write: -Code With Mosh- Mastering JavaScript Unit Testing
