You are previewing Test-Driven JavaScript Development.

Test-Driven JavaScript Development

Cover of Test-Driven JavaScript Development by Christian Johansen Published by Addison-Wesley Professional
O'Reilly logo

Chapter 15. TDD and DOM Manipulation: The Chat Client

Developing client-side JavaScript includes a fair amount of DOM manipulation. In this chapter we will use test-driven development to implement a client for the chat backend we developed in Chapter 14, Server-Side JavaScript with Node.js. By doing so we will see how to apply the techniques we have learned so far to test DOM manipulation and event handling.

The DOM is an API just like any other, which means that testing it should be fairly straightforward so long as we adhere to the single responsibility principle and keep components loosely coupled. The DOM does potentially present a challenge in that it consists entirely of host objects, but as we will see, we can work around the potential ...

The best content for your career. Discover unlimited learning on demand for around $1/day.