Getting Started

Testing an existing piece of software holds a different set of challenges from testing something you are writing, particularly if it is of any size. The Timepicker Addon had just over 2100 lines of code when I started.

You first need to choose where to start. Testable entities—functions in JavaScript—that have few or no dependencies, provide you a way to start with something simpler—a way to get a foothold—and work your way up the chain. The first commit, of course, was just setting up the test framework [72007f6].

I chose to start with a series of top-level private functions within the immediately invoked function expression (IIFE) that wraps every well-written jQuery plugin. But the functions were private, so I had to decide ...

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.