WHAT’S IN THIS CHAPTER?
- Using the Jasmine unit-testing framework to prove the reliability of each component of your code
- Using a dependency-injection (DI) container to promote modularity, reusability, and testability
- Exploring how aspect-oriented programming (AOP) can make your code simpler and more reliable
- Exploring case studies in test-driven development
- Using JSLint to detect problems in your code before it ships
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at
You can run a sample by copying its directory to your hard drive and double-clicking on the
index.html file. Each sample’s
ReadMe.txt file contains further instructions.
USING A TESTING FRAMEWORK
Assume for a moment that you’re working on a large team that’s building a travel reservation system. You’re responsible for the module that creates flight reservations, and one of the module functions should behave as follows: Given a passenger object and a flight object,
createReservation will return a new object with the
passengerInformation property set to the provided passenger object and the
flightInformation property set to the provided flight object.
Simple enough, right? So simple, in fact, that there’s no harm in just going ...