**In this article, we will **go in detail through creating a testing setup which:
- Operates on “clean slate” every time, but still works fast by running tests in parallel.
- Tests the app by simulating user’s actions, instead of testing the output of individual functions and methods with mock data.
- Is powerful enough to test every corner of the app, including parts that require login.
- Is expandable, but concise enough for easy maintenance or onboarding of new developers.
As well as:
- Write wrapper class and factory functions, taking DRY principle seriously.
- Explore the legit real-life use case for ES6 Proxy/Reflect.
- 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