6 Testing frontend applications

This chapter covers

  • Replicating a browser’s JavaScript environment in your tests
  • Asserting on DOM elements
  • Handling and testing events
  • Writing tests involving browser APIs
  • Handling HTTP requests and WebSocket connections

Trying to write a client-side application without using JavaScript is as difficult as baking a dessert without carbohydrates. JavaScript was born to conquer the web, and in browsers, it has shone.

In this chapter, we’ll cover the fundamentals of testing frontend applications. Together, we’ll build a small web client for the backend we wrote in chapter 4 and learn how to test it.

During the process of building and testing this application, I’ll explain the peculiarities of running JavaScript ...

Get Testing JavaScript Applications 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.