stryker-tsgo-checker
v0.1.0
Published
Experimental StrykerJS checker plugin that type-checks mutants with tsgo (the native TypeScript compiler), for much faster mutation testing.
Maintainers
Readme
stryker-tsgo-checker
Experimental StrykerJS checker plugin that type-checks mutants with tsgo, the native TypeScript compiler: 3.6× faster (54s→15s) on one 238-mutant / 5-file project; your numbers will vary.
Install
npm i -D stryker-tsgo-checker @stryker-mutator/typescript-checkerAdd the checker to your Stryker config:
{
"checkers": ["tsgo"],
"appendPlugins": ["stryker-tsgo-checker"],
"tsconfigFile": "tsconfig.json"
}Use appendPlugins, not plugins. plugins overwrites Stryker's defaults and can break your test runner.
The parity tool uses the official typescript checker as the tsc baseline, so @stryker-mutator/typescript-checker must be installed alongside this package.
⚠️ Experimental — verify parity before trusting your score
This package uses @typescript/native-preview, a pre-GA TypeScript compiler preview with APIs under unstable/* paths. Mutation-score correctness depends on tsgo classifying compile-error mutants the same way tsc does for your codebase.
A mismatch can silently skew the score:
- tsc reports
CompileError, tsgo does not: the mutant may run and survive even though it should be excluded. - tsgo reports
CompileError, tsc does not: a valid mutant may be excluded, inflating the score.
Run the parity gate before trusting tsgo results:
npx stryker-tsgo-parityOnly trust the tsgo score if the command exits 0. The package pins @typescript/native-preview exactly because the preview API and diagnostics can change between date-stamped builds. Re-run parity on every bump.
The current pin was parity-checked on one real project: 5 files, 238 mutants, 54 matching CompileError mutants.
How it works
stryker-tsgo-checker keeps one resident tsgo API instance from @typescript/native-preview/unstable/sync. It gives tsgo a virtual file system that reads from disk but overlays mutant contents in memory. For each single-mutant group, the checker writes the mutated file into the overlay, calls updateSnapshot({ fileChanges }), reads structured semantic diagnostics, maps TypeScript error diagnostics to Stryker's CompileError, then restores the original file in the overlay.
That means no subprocess per mutant and no stderr parsing.
Limitations
- 0.x targets one tsconfig project. It does not implement
--buildor TypeScript project-reference orchestration. - The project must typecheck cleanly under tsgo before mutation checking starts. Baseline tsgo errors abort the checker.
- The parity tool supports JSON Stryker configs in 0.x. If your config is
.jsor.mjs, convert it to JSON for the parity run.
License
CC0-1.0. Public domain. Copy it, fork it, upstream it, and remove attribution if that helps Stryker absorb the idea.
