Jest is a batteries included unit testing framework by Facebook. It's fast, feature rich, and integrates perfectly with Babel, an important tool our build pipeline. Jest allows for an exceptional unit testing experience.

However I've never been able to say that about acceptance testing. Could we integrate high-level, end-to-end tests and maintain the same experience?

Nightmare, an Electron powered high-level browser automation library, gets us really close. Using Nightmare, we can spin up a headless browser and perform user actions from any testing framework that leans on NodeJS.

Jest is one of those frameworks. In this blog post, I'll walk through how I set up Jest and Nightmare on my most recent project for great testing success.

Sample Boilerplate

This blog post builds from a setup I've created that leans on create-react-app. Feel free to check it out, or keep following along.

Using Jest

Before getting into Nightmare, let's look at a basic unit test: