**In this article, we will **go in detail through creating a testing setup which:

  1. Operates on “clean slate” every time, but still works fast by running tests in parallel.
  2. Tests the app by simulating user’s actions, instead of testing the output of individual functions and methods with mock data.
  3. Is powerful enough to test every corner of the app, including parts that require login.
  4. Is expandable, but concise enough for easy maintenance or onboarding of new developers.

As well as:

  1. Write wrapper class and factory functions, taking DRY principle seriously.
  2. Explore the legit real-life use case for ES6 Proxy/Reflect.
  3. Create easy bulk route testing that will run in parallel with Promise.all

Packages used:

  • jest — as a testing library to run tests suites.
  • puppeteer — as a way to run a headless chrome browser.
  • Keygrip — to sign some cookies.

The app that we are testing:

  • “Private blog” — MERN stack app made with Mongo/Mongoose, Express, React, Node.
  • Passport and google OAuth as a means to handle authentication/authorization.

Full working app can be found on my GutHub.

#react #javascript #puppeteer #jest #testing

 Road the Ultimate Testing Setup With Jest and Headless Chrome Browser
5.05 GEEK