stryker-js: Static mutants not being ignored

Summary Static mutants still seem to be considered in the reporting despite running with the --ignoreStatic flag. This seems to potentially be limited to just the ArrowFunction mutants so far.

We are using Stryker with Jest in a NextJS project. We split our components up into an index.js and a helpers.js file. The ArrowFunction mutants that we’re having issues with are always generated in these helper.js files, and stryker seems to fail to run any tests for these mutants so they survive everytime. Running without the --ignoreStatic flag causes these tests to run and kill these mutants. This is an issue for us as we enforce 100% of mutants killed in our CI pipelines.

image

I think this is possibly just an error with how reporting is being done for these mutants, as stryker seems to be ignoring them when running tests, but accounting for them in coverage reports.

Right now we are just using // Stryker disable next-line ArrowFunction where needed, but may move to disabling this mutant globally. This is obviously not ideal but we’ve been struggling to find another solution.

Stryker config This is the content of our stryker.conf.mjs file:

const config = {
  packageManager: 'yarn',
  reporters: [
    'clear-text',
    'html',
    'progress'
  ],
  testRunner: 'jest',
  jest: {
    projectType: 'custom',
    configFile: 'jest.config.js'
  },
  coverageAnalysis: 'perTest',
  ignorePatterns: ['/node_modules/', '/.next/'],
  logLevel: 'info',
  mutate: [
    'src/**/*.js',
    '!src/**/*styles.js',
    '!src/**/*constants.js',
    '!src/constants/*.js'
  ],
  timeoutMS: 15000
}

export default config

Test runner config This is the content of our jest.config.js file:

module.exports = {
  clearMocks: true,

  setupFilesAfterEnv: ['<rootDir>/test/setup.js'],

  testPathIgnorePatterns: ['/node_modules/', '/.next/'],

  transformIgnorePatterns: [
    'node_modules/(?!@internal)'
  ],

  collectCoverageFrom: [
    'src/**/*.js'
  ],

  coverageThreshold: {
    global: {
      branches: 100,
      functions: 100,
      lines: 100,
      statements: 100
    }
  },

  moduleNameMapper: {
    '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/test/__mocks__/fileMock.js',
    '@components/(.*)': '<rootDir>/src/components/$1',
    '@constants/(.*)': '<rootDir>/src/constants/$1',
    '@helpers/(.*)': '<rootDir>/src/helpers/$1',
    '@hooks/(.*)': '<rootDir>/src/hooks/$1',
    '@root/(.*)': '<rootDir>/$1',
    '@scripts/(.*)': '<rootDir>/src/scripts/$1',
    '@src/(.*)': '<rootDir>/src/$1',
    '@tracker/(.*)': '<rootDir>/src/tracker/$1'
  },

  testEnvironment: 'jsdom',

  transform: {
    '^.+\\.js?$': '<rootDir>/node_modules/babel-jest'
  }
}

Stryker environment

├─ @stryker-mutator/api@6.1.2
├─ @stryker-mutator/core@6.1.2
├─ @stryker-mutator/instrumenter@6.1.2
├─ @stryker-mutator/jest-runner@6.1.2
└─ @stryker-mutator/util@6.1.2
├─ jest@29.1.2
├─ jest-environment-jsdon@29.1.2
├─ jest-next-dynamic@1.0.1
├─ babel-jest@29.1.2
├─ @testing-library/dom@8.11.1
├─ @testing-library/jest-dom@5.16.4
├─ @testing-library/react-hooks@8.0.1
├─ @testing-library/react@13.3.0
└─ @testing-library/user-event@14.4.3

Test runner environment

NODE_ENV=test jest ./test

Your Environment

software version(s)
node 16.17.1
npm N/A
yarn 1.22.19
Operating System Ubuntu 20.04

stryker.log stryker.log

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Another update: still not been able to put the time aside for this.

Black Friday and the lead up to Christmas is a very busy period for us so I’ve just not had the capacity at all. Thankfully with the end of the month coming up things will slow down and most people will be away for the holidays, which should definitely allow me to focus on getting a sample repo for you @nicojs

Sorry about the delays, and thank you for your patience.

@nicojs I had a quick attempt at this but our project is quite a substantial one, so trying to pull out everything sensitive broke a lot of things. I’ll try put some time aside during my next sprint to see if I can clean up the repo and keep everything working.