Analysing Jest test performance

Introduction

The is an example project used for the purposes of a blog article to analyse and explain some of the reasons for Jest performance problems.

The project is based on a basic React app bootstrapped using the well-known Create React App tool.

Getting started

  • Clone repository
  • Install the dependencies: npm install
  • Start an ndb profiling session in a Chromium browser: npm run profile
  • Then, in the scripts side bar under the sources tab, we can record profiling information for the various npm scripts (which contain sample test cases) by clicking the ⏺ button next to those scripts.

Test cases

  1. test1: the benchmark test using the sample code and sample test generated by Create React App
  2. test2: importing a Material UI button component from the package's barrel file
  3. test3: importing a Material UI button component via a deep import
  4. test4: using automocking to mock the Material UI component library
  5. test5: using factory mocking to mock the Material UI component library