@systemfsoftware/stryker-ignorer-in-source-vitest-block
v0.1.1
Published
Stryker ignorer that removes mutants inside `if (import.meta.vitest)` guards — test code unreachable in a mutation run.
Maintainers
Readme
@systemfsoftware/stryker-ignorer-in-source-vitest-block
In-source tests are not production behavior. Stop their mutants from dragging your Stryker score below 100%.
Your if (import.meta.vitest) blocks are stripped before production, so code executing during mutation testing never reaches them. They sit in reports as false unkillable survivors.
This Stryker ignorer recognizes and skips mutants inside import.meta.vitest test guards, ensuring 100% mutation testing accuracy.
Install
pnpm add -D @systemfsoftware/stryker-ignorer-in-source-vitest-blockSetup in stryker.config.ts
Add the plugin URL to ignorers. Every ignorer the module exports is then active.
import { defineConfig } from '@systemfsoftware/stryker-js/config'
export default defineConfig({
testRunner: {
plugin: import.meta.resolve('@systemfsoftware/stryker-js-vitest-runner'),
},
ignorers: [
import.meta.resolve('@systemfsoftware/stryker-ignorer-in-source-vitest-block'),
],
})Mutants inside guarded test blocks are reported as Ignored.
What It Ignores
| Guard Shape | Example |
| ---------------------------------- | ----------------------------------------------------- |
| Direct Vitest meta property check | if (import.meta.vitest) { ... } |
| Comparison check | if (import.meta.vitest !== undefined) { ... } |
| Enclosed declarations and fixtures | All test suites and utilities nested within the block |
