Chapter 7
Testing with Intern

Much has been said about the difficulties of testing in JavaScript. It’s not so much the language as what the language is primarily used for: building interactive applications on the Web. Rocket science is hard, but writing tests for rocket software is relatively easy, because you only need to test that it computes the correct trajectories. Conversely, it’s easy to build a web application, but writing good tests—the kind that will find bugs before your users do—is a challenge.

Still, it’s a challenge worth facing head-on. The JavaScript testing ecosystem is light years beyond where it was just a few years ago. Test frameworks of all kinds have proliferated. Build systems that run automated tests before deploying a new version of a script have become the norm.

In this chapter, we’ll write tests for the project from the previous chapter. We’ll start by testing the UI in isolation, using mock Ajax. Then we’ll test the Node server in isolation. Together, these tests will run rapidly while ensuring that both ends of our application behave as expected. And we’ll implement both layers of testing using a single framework, Intern.[52]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.134.198