ternTS · Guide
A faster Jest transform for TypeScript.
Most of a TypeScript test run under ts-jest goes to compiling your test files. ternTS does that part 9× faster, with the same output tsc would give, and you switch with one line of config.
Switch in one line
npm i -D @ternlang/ternts@experimentalFrom ts-jest
// jest.config.js
module.exports = {
transform: {
'^.+\\.(t|j|mj)sx?$': ['@ternlang/ternts/jest', { tsconfig: 'tsconfig.json' }],
},
};Remove preset: 'ts-jest' if you have it. ternTS reads tsconfig.json from Jest’s rootDir by default, so { tsconfig: ... } is only needed for another file (or false for none).
From @swc/jest
Replace '@swc/jest' with '@ternlang/ternts/jest' in the same transform entry, and you can delete .swcrc: the options come from your tsconfig, as they do for tsc.
What it does for you
- tsc’s exact output. What runs in your tests is what
tscwould have built: legacy decorators withemitDecoratorMetadata(NestJS, TypeORM, Angular), enums, namespaces,useDefineForClassFields, JSX in all four modes. jest.mock()hoisting, as babel-jest, @swc/jest and ts-jest do it.- ES module JavaScript (
.js,.mjs) becomes CommonJS, so ESM-only packages run under Jest’s CommonJS runtime. - Source maps, so stack traces and coverage point at your TypeScript lines.
- Jest’s cache works as usual: its keys include your options and the ternTS build.
It’s been run against real suites: all 3,631 of Nest’s unit tests pass with it, and so do Immich’s server tests.
Vitest
Vitest compiles TypeScript with esbuild, which doesn’t emit decorator metadata. The ternTS plugin compiles it the way tsc does instead:
// vitest.config.ts
import { defineConfig } from 'vitest/config';
import ternts from '@ternlang/ternts/vite';
export default defineConfig({ plugins: [ternts()] });What it doesn’t do
Like @swc/jest, it doesn’t type check. ts-jest’s isolatedModules: false mode reports type errors while tests run; with ternTS, run tsc --noEmit separately. ternTS is experimental: if a test behaves differently than under ts-jest, please open an issue.
Apple M4 Pro, Node 24. Each transformer’s own process() over all 1,959 files of the NestJS repository in one process, best of three passes, no Jest cache; ts-jest in its faster isolatedModules mode, so a default ts-jest setup is slower still. node bench/jest.mjs in the ternTS repository reproduces it.