Adding roots to Jest config
Created by: mucsi96
Is your proposal related to a problem?
My problem is that Jest test are running slow. I have tried CRA with TypeScript using npx create-react-app my-app --typescript. After that executing npm test on Windows 10 machine took 35 seconds. I started to investigate why it's so slow. After making a CPU profile I saw huge number of calls to graceful-fs readdir function. After adding a console.log there I discovered that the function was called on every directory inside .git and node_modules folders. See attached log.
Describe the solution you'd like
To try to improve the performance I have added roots: ['<rootDir>/src'], to createJestConfig.js. After that there were no readdir calls apart from src folder. With that the test execution time went down to 20 seconds. This is a 43% speed improvement on my machine.