Chapter 8. Unit testing
This chapter covers
- An introduction to unit testing
- Using JavaScript testing frameworks
- Unit testing MV* objects
- An introduction to behavior-driven development unit testing
When you create software, regardless of the platform or language used, you want to do your best to ensure that you’re delivering a quality product. In this book, you’ve looked at various ways to create a maintainable, robust SPA, such as dividing your code into modules and using the power of MV* frameworks. Another vital facet of SPA programming is testing. Testing what you write is just as important to the delivery of the end product as the code itself. Putting your code through the paces does a lot more than uncover bugs. When you see that your code does what you expect it to and can handle failures gracefully, this helps you write better code and improves your confidence in the application.
Although an application can be subjected to a variety of tests, this chapter focuses specifically on unit testing. The upcoming sections cover what a unit test is, how to create code that’s more conducive to unit testing, and what some of the benefits are. Even though certain aspects of unit testing are subjective, we can zero in on some of its most common features.