Tip 32Write Functions for Testability

I had a literature professor who said that classes about writing don’t include enough reading and classes about reading don’t include enough writing. The same is true of code and tests: Books about code don’t talk enough about testing and books about testing don’t talk enough about composing code.

Time to fix that. Testing is important. If you don’t do it, you should. It makes your code easier to refactor. It makes legacy code much easier to understand. And it generally results in cleaner, less buggy applications.

Most developers agree with this. Why then is testing neglected?

It’s simple. Writing tests is hard. Or more accurately, many developers think writing tests is hard because they try ...

Get Simplifying JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.