Hacker News new | ask | show | jobs
by jasonjmcghee 434 days ago
Yes exactly. If you're writing a library, unit tests are likely a great investment. Your "customers" are using the things you are testing.

If you're writing an API, your customers are calling the endpoints. Very important they behave properly on happy path and fail appropriately when they should (permissions / security especially)

(I also ensure tests in the service/dao layer to protect developers from footguns and/or more "unexpected" behavior, but I'd argue the API layer is generally more important)

If you're writing a react app, playwright is very important (and using it properly / acting like a real user) as your customers are interacting with it via a browser.

Though the larger the codebase/ when you start having reusable components, the better tested they are, the less will go wrong in the future as an unfamiliar developer will inevitably hold it wrong.