[Performance] Jest tests have a lot of overhead that makes them take a really long time to run.
msnyder-msft opened this issue · 0 comments
Describe the bug
The jest tests are taking far long than individual tests actually take. There is a lot of time on each suite getting spent doing some kind of overhead. Each test only takes 1-3ms but the suite will take 40-60 seconds. When I profiled it I can see the test only taking a fraction of the time and there are a ton of imports. I suspect it is importing far more files than we actually need in each test. I've read that importing from index files can cause this so we should try to avoid that when importing files within our own solution. When it comes to importing from modules, if we import from the root index then we will import the entire module so we should look at trying to mock out the larger libraries like Fluent or Babylon.
To Reproduce
Steps to reproduce the behavior:
- Run any test suite in the app
npm run test:watch BehaviorFormContext
Expected behavior
A test suite should take under 5 seconds consistently.