Trying mutation testing with @mizchi/mutator in a TypeScript monorepo
A Zenn article by the author polyco describes trying @mizchi/mutator in a TypeScript business app with a pnpm monorepo and Vitest 5. Mutation testing[1] changes one place in the code, such as <= to <, and runs the tests: if a test fails, the change is caught; if every test passes, the change is a surviving mutation[2], which points to a possible gap in the tests. In 13 critical files of the web package, the tool created 2,977 mutations and 667 survived; 540 of these were errors the tests missed, and the author added about 230 tests to catch them, while 127 mutations that did not change behavior were excluded with a stated reason.
Among the 39 critical files across four packages, the missed errors were mostly boundary values and rare cases. Few tests could be removed: in the estimate and construction tests of the API (2,449 tests), AI proposed 2,710 candidates, and only 3 were judged safe to delete. On the same 2 files and 169 tests, mutator took 997 seconds for its first run against 2,570 seconds for StrykerJS, and a second run with no changes took 0.5 seconds against 47 seconds.
The author added the mutation checks to the develop workflow skill, so the AI runs them right after each fix, and results carry over between git worktrees through a shared folder. mutator cannot try every kind of break, so the author kept the manual check where the AI breaks the implementation on purpose and confirms that a test fails.
Sources
-
JPZenn JA
mizchi/mutator を入れてみた


