Chapter 15. Legacy JavaScript

Michael Feathers defines legacy code as code without tests [WEwLC]. JavaScript and other dynamic languages benefit from tests by exercising a wider range of the dynamic behaviors that sometimes make them behave in unanticipated ways. Open-source projects benefit from tests so that multiple contributors can make changes without each having to be intimately familiar with all behaviors.

In contrast, open-source JavaScript projects without tests survive through simplicity or a small number of immersed maintainers, and often both. Increasingly, open-source JavaScript projects include tests, but some very useful and popular projects remain without them.

The jQuery Timepicker Addon1 by Trent Richardson is one such project. ...

Get Quality Code: Software Testing Principles, Practices, and Patterns 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.