Appendix B. Testing JavaScript with QUnit
Throughout this book, we have written a lot of JavaScript code, and we have seen the many ways in which jQuery helps us write this code with relative ease. Yet, whenever we have added a new feature, we have had to take the extra step of manually checking our web page to ensure that everything is working as expected. While this process may work for simple tasks, as projects grow in size and complexity, manual testing can become quite onerous. New requirements can introduce "regression bugs" that break parts of the script that previously worked well. It is far too easy to miss these bugs that don't specifically relate to the latest code changes because we naturally only test for what we have just done.
What we need instead is an automated system that runs our tests for us. The QUnit testing framework is such a system. While there are many other testing frameworks, and they all have their own benefits, we recommend QUnit for most jQuery projects because it is written and maintained by the jQuery project. In fact, jQuery itself uses QUnit (running nearly 5,000 tests!).