Chapter 17. Writing Good Unit Tests

Unit tests can be an incredible asset. When writing tests as part of the test-driven development cycle, tests help form the design of production code, provide us with an indication of progress, and help us scope down and only implement what we really need. When writing tests after the fact, they help form a suite of regression tests and a security net in which we can comfortably refactor code. However, simply adding unit tests to a project will not magically fix it. Bad tests not only provide little value, they can do actual damage to productivity and the ability to evolve the code base.

Writing good tests is a craft. Even if you already are a skilled programmer, you will find that getting good at writing ...

Get Test-Driven JavaScript Development 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.