CHAPTER 2 Tooling Up
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 www.wrox.com/go/ reliablejavascript
on the Download Code tab. The code is in the Chapter 2 download and organized in directories according to this chapter’s topics, with each directory holding one sample.
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 ...
Get Reliable JavaScript: How to Code Safely in the World's Most Dangerous Language 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.