TIL: Speed up jest tests (2)

Use esbuild-jest to speed up TypeScript tests

Profile pictureToni Petrina
Published on 2021-07-101 min read
  • #today-i-learned
  • #jest
  • #esbuild

Last time some jest.config.js trickery was used to speed up Jest tests.

However, there is something that can make it faster - better compiler. And in this case it is esbuild.

First, add packages esbuild and esbuild-jest. Then add the following to jest.config.js:

  transform: {
    "^.+\\.tsx?$": "esbuild-jest",
  },

Also, remove preset: "ts-jest", from jest.config.js if found. From more than 3 seconds to 0.12s. Fantastic!


Change code theme: