@swc/jest
To make your Jest tests run faster, you can swap out the default JavaScript-based runner (ts-jest) for a drop-in Rust replacement using SWC.
Installation
Usage
Inside jest.config.js, configure Jest to use SWC:
It will load the SWC configuration from .swcrc by default. You also can customize it:
Q & A
Q: Jest uses CommonJS by default. But I want to use ESM
A: Setup Jest following this Guide.
For JavaScript, edit package.json as follows:
For TypeScript, edit jest.config.js as follows:
Run test with --experimental-vm-modules:
Q: What ECMAScript target is set by jsc.target?
A: By default, the version supported by your Node runtime.
You can customize this by setting an explicit version in jest.config.js:
