Integration with Jest
Jest + ts-jest is the primary environment Forger is developed and tested in. The key points: use the ts-patch compiler inside ts-jest and register Forger's transformer.
1. Install dependencies
2. Configure ts-jest
The transformer must run for the spec files — this is where Forger.create<T>() calls live:
Two things matter:
compiler: 'ts-patch/compiler'— the patched TypeScript compiler that executesplugins-declared transformers;astTransformers.before— Forger's transformer, applied to the AST before ts-jest transpiles the spec.
Alternative: project-wide tsconfig plugins
Instead of (or in addition to) astTransformers, declare the transformer in tsconfig.json:
With ts-patch/compiler as the ts-jest compiler, plugins declared this way are picked up automatically. This is the setup the Forger repository itself uses for its own test suite.
Isolated config variant
For suites that run specs in separate processes, a globals-based config also works (this is the jest-isolated.config.js variant used in the Forger repository):
Sanity check
If this fails with undefined, the transformer is not being applied — re-check step 2. See Caveats.
Related
Installation — the full setup walkthrough.
Integration with Angular — Karma and application builds.
Building with ts-patch — non-Jest pipelines.