Skip to content

Jest spends several seconds in loadTSConfigFile before running tests #11337

@jtbandes

Description

@jtbandes

🐛 Bug Report

I am working in a yarn 2 monorepo that has a handful of separate TypeScript packages. When running Jest on a small test file, it takes about 8 seconds before the test even starts running. During this time it seems like Jest is running loadTSConfigFile and processing all the tsconfig files in our repo:

image

To help address I created a custom tsconfig for jest, but needed to keep some of the typeRoots. This helped somewhat but the performance is still quite poor. I'd appreciate any advice on how to speed things up! Why does it take so long for jest to process these config files? Should I convert them all to jest.config.json instead of jest.config.ts?

To Reproduce

Steps to reproduce the behavior:

  • Check out this repo @ 2a41078a and run yarn.
  • Run yarn test app/util/time.test.ts. Or yarn test:debug app/util/time.test.ts to inspect with Chrome dev tools.

Expected behavior

The test file is small, so it should run quickly.

Link to repl or repo (highly encouraged)

https://github.com/foxglove/studio/tree/2a41078ac99f3a636e4288c31bb188e54a9f2ed3

envinfo

  System:
    OS: macOS 11.2.3
    CPU: (8) arm64 Apple M1
  Binaries:
    Node: 15.9.0 - ~/.nvm/versions/node/v15.9.0/bin/node
    Yarn: 2.4.1 - ~/.nvm/versions/node/v15.9.0/bin/yarn
    npm: 7.5.4 - ~/.nvm/versions/node/v15.9.0/bin/npm
  npmPackages:
    jest: 27.0.0-next.8 => 27.0.0-next.8 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions