Chapter 2. Arming with testing and debugging

 

This chapter covers

  • Tools for debugging JavaScript code
  • Techniques for generating tests
  • Building a test suite
  • How to test asynchronous operations

Constructing effective test suites for your code is always important, so we’re going to discuss it now, before we go into any discussions on coding. As important as a solid testing strategy is for all code, it can be crucial for situations where external factors have the potential to affect the operation of your code, which is exactly the case we’re faced with in cross-browser JavaScript development.

Not only do we have the typical problems of ensuring the quality of the code, especially when dealing with multiple developers working on a single code base, and guarding against regressions that could break portions of an API (generic problems that all programmers need to deal with), but we also have the problem of determining if our code works in all the browsers that we choose to support.

We’ll further discuss the problem of cross-browser development in depth when we look at cross-browser strategies in chapter 11, but for now, it’s vital that the importance of testing be emphasized and testing strategies defined, because we’ll be using these strategies throughout the rest of the book.

In this chapter, we’re going to look at some tools and techniques for debugging JavaScript code, for generating tests based upon those results, and for constructing a test suite to reliably run those tests.

2.1. Debugging code

2.2. Test generation

2.3. Testing frameworks

2.4. The fundamentals of a test suite

2.5. Summary

sitemap