I've been trying to run Stryker on my typescript repo for a while, and continue to get surviving mutants where I don't think they should be. I have manually added some of the mutants to my codebase, and my tests fail - some for compilation reasons, but generally because the code is properly under test.
NB - I'm working on mac, I know there have been similar questions on windows
Any ideas?
stryker.conf.json:
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"_comment": "This config was generated using 'stryker init'. Please take a look at: https://stryker-mutator.io/docs/stryker-js/configuration/ for more information.",
"checkers": ["typescript"],
"coverageAnalysis": "perTest",
"ignoreStatic": true,
"logLevel": "info",
"mutate": ["src/**/*.ts"],
"packageManager": "npm",
"reporters": ["html", "clear-text", "progress"],
"thresholds": { "high": 80, "low": 60, "break": null },
"testRunner": "jest",
"tsconfigFile": "tsconfig.json",
"typescriptChecker": {
"prioritizePerformanceOverAccuracy": true
}
}
jest.config.js:
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.ts', '**/?(*.)test.ts'],
testPathIgnorePatterns: [
'node_modules',
'.cache',
'public',
],
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/__utils__/*.ts',
],
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
setupFiles: ['./.jest/setEnvVars.js'],
silent: true,
reporters: [
'default',
[
'jest-junit',
{ outputDirectory: './test-results', outputName: 'jest.xml' },
],
],
};
tsconfig.json:
{
"compilerOptions": {
"lib": [
"ESNext",
"DOM"
],
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"removeComments": true,
"preserveConstEnums": true,
"strict": true,
"alwaysStrict": true,
"strictPropertyInitialization": false,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowUnreachableCode": false,
"noFallthroughCasesInSwitch": true,
"target": "ESNext",
"outDir": ".build",
"declaration": true,
"sourceMap": true,
"baseUrl": ".",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": false,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"exclude": ["./.build/**/*", "./node_modules/**/*"]
}
versions:
"@stryker-mutator/core": "^7.1.1",
"@stryker-mutator/jest-runner": "^7.1.1",
"@stryker-mutator/typescript-checker": "^7.1.1",
...
"ts-jest": "^27.0.4",
"typescript": "^4.3.5"