Chapter 8. Testing JavaScript components
This chapter covers
- Applying unit testing fundamentals to JavaScript components
- Writing unit tests in Tape
- Mocking, spying, and proxying
- Testing browsers hands-on
- Using Grunt for test automation
- Understanding integration and visual testing
By writing tests, you’ll improve the reliability of the modules and applications you build and insure they work the way you intend. In typical Build First fashion, you’ll get the necessary insight to automate those tests and run them on the cloud. This chapter includes a few guidelines that will help you write tests, and you will also get hands-on experience in testing components. In some cases I’ll walk you through the tests that you may write for a given piece of code, helping you visualize the thought process behind writing thoughtful unit tests.
While I’m not an advocate for the Test-Driven Development (TDD) paradigm, which encourages you to write tests before you develop any functionality, I think tests are important, and you should write them. In this chapter we’ll go back and forth between process design and application design. You’ll look at how to write tests, and then I’ll give you the tools to automate testing.