Chapter 9Testing JavaScript: Integration Testing

Nearly every Rails site uses JavaScript for something, and often JavaScript is a critical part of the user experience on sites. However, many sites don’t test their JavaScript in any meaningful way.

Part of the reason is that JavaScript can be difficult to test. Interactions and logic are often dependent on user interaction or the specific state of the elements on the page, which can be hard to set up for testing. Often the JavaScript frameworks don’t support easy unit testing. And the tools are changing very quickly. The tools I use in this chapter may seem quaint if not downright antiquated by the time you read this.

That said, some general principles for testing JavaScript will continue to ...

Get Rails 5 Test Prescriptions 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.