Interview practice question
Testing a price formatting function
Frontend Engineering · Testing and Tooling · Beginner
How would you write unit tests for a function that formats prices, like formatPrice(1234.5, "USD")?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Typical inputs and expected outputs.
- Edge cases: zero, negatives, rounding, large numbers.
- Different currencies/locales.
- Table-driven tests (test.each).
- Pure function: no mocks needed.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.