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
test1
: the benchmark test using the sample code and sample test generated by Create React Apptest2
: importing a Material UI button component from the package's barrel filetest3
: importing a Material UI button component via a deep importtest4
: using automocking to mock the Material UI component librarytest5
: using factory mocking to mock the Material UI component library