stryker-mutator / stryker-js

Mutation testing for JavaScript and friends
https://stryker-mutator.io
Apache License 2.0
2.6k stars 251 forks source link

Stryker do not update mutation coverage after adding new tests #5017

Open mykhailokonst opened 1 month ago

mykhailokonst commented 1 month ago

Question

I ran initial mutation tests. After checking some react component, I add some tests to increase its mutation coverage. I checked these new tests are failng in case of specific mutations manually. But after new stryker run, the report did not changed correctly. If I delete incremental file, and run tests from scratch, it show correct coverage.

Stryker environment

"@stryker-mutator/core": "^7.2.0",
"@stryker-mutator/jest-runner": "^7.2.0",
+-- jest@29.5.0

Additional context

module.exports = {
  concurrency: 6,
  coverageAnalysis: "all",
  disableTypeChecks: "{test,src,lib}/**/*.{js,ts,jsx,tsx,html}",
  dryRunTimeoutMinutes: 50,
  htmlReporter: { fileName: "reports/stryker/stryker.html" },
  ignoreStatic: false,
  incremental: true,
  incrementalFile: "stryker-config/stryker-temp.json",
  jest: {
    configFile: "config/jest.config.js",
  },
  jsonReporter: { fileName: "reports/stryker/stryker.json" },
  mutate: [
    // "src/**/*.{js,jsx,ts,tsx}",
    //Stryker Exclusions:
    "!src/shared/constants/**/*.{js,jsx,ts,tsx}",
    // General Exclusions
    "!src/{i18n,services,modules,types}/**/*",
    "!src/**/module.*",
    "!src/**/modules.*",
    "!src/**/routes.*",
    "!src/**/types.*",

    // Specific Exclusions
    "!src/{main.{js,ts,jsx,tsx},polyfills.js}",
    "!src/{tools,icons,testing}/**/*",

    // Aligment with jest.config.js
    "!src/{fixtures,test,__tests__,testing}/**/*",
    "!src/**/*.test.*",
    "!src/**/*.spec.*",
  ],
  mutator: {
    excludedMutations: ["StringLiteral", "ArrayDeclaration", "MethodExpression", "ObjectLiteral", "OptionalChaining"],
  },
  packageManager: "npm", // Default: 5
  reporters: ["clear-text", "progress", "html", "json"],
  tempDirName: ".stryker-tmp",
  testRunner: "jest",
  testRunnerNodeArgs: ["--no-compilation-cache", "--max-old-space-size=6144", "--expose-gc"],
  timeoutFactor: 6,
  timeoutMS: 600000,
};
nicojs commented 1 month ago

This seems to work as expected. You're running with coverageAnalysis: "all", which means that StrykerJS cannot detect the specific coverage of newly added tests. Could you try running with coverageAnalysis: "perTest"?

Hmm this should be documented in the limitations docs 🤔

mykhailokonst commented 1 month ago

@nicojs , I try to run the stryker with perTest value. But I faced with such error:

Screenshot 2024-10-03 at 15 25 08 Screenshot 2024-10-03 at 15 25 15
mykhailokonst commented 1 month ago

I am out of RAM memory each run