TIL: Speed up jest tests (2)

July 10, 2021

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!