Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enableFindRelatedTests seems to not work in jest plugin #1566

Closed
jRichardeau opened this issue May 29, 2019 · 12 comments
Closed

enableFindRelatedTests seems to not work in jest plugin #1566

jRichardeau opened this issue May 29, 2019 · 12 comments

Comments

@jRichardeau
Copy link

Summary

I'm using stryker in a React application with jest.

When using the enableFindRelatedTests option of jest plugin and running stryker on all my files, all mutants are surviving as if no tests were ran (but it takes 4h :P).

If I add the -m option on the command line to target one file it's working for it.

Moreover running jest with --findRelatedTests is ok.

Stryker config

module.exports = function(config) {
   config.set({
      mutate: ["source/**/*.js", "!source/**/*@(.test|.spec|Spec).js", "!source/scripts/**/*.*"],
      files: [
         '*.js', 
         '__mocks__/*.js',
         'testUtils/*.js',
         'source/**/*.js?(on)',
         "!source/scripts/**/*.*"
      ],
      mutator: "javascript",
      packageManager: "yarn",
      reporters: ["html", "clear-text", "progress"],
      htmlReporter: {
         baseDir: 'stryker-reports/mutation/html'
      },
      testRunner: "jest",
      coverageAnalysis: "off",
      jest: {
         projectType: "custom",
         config: require('./jestrc.json'),
         enableFindRelatedTests: true
      },
      symlinkNodeModules: false
   });
};

Stryker environment

+-- @stryker-mutator/core@2.0.0
| +-- @stryker-mutator/api@2.0.0
| +-- @stryker-mutator/util@2.0.0
+-- @stryker-mutator/html-reporter@2.0.0
| +-- @stryker-mutator/api@2.0.0 deduped
| +-- @stryker-mutator/util@2.0.0 deduped
+-- @stryker-mutator/javascript-mutator@2.0.0
| +-- @stryker-mutator/api@2.0.0 deduped
+-- @stryker-mutator/jest-runner@2.0.0
| +-- @stryker-mutator/api@2.0.0 deduped
+-- jest@24.5.0
+-- enzyme@3.9.0
+-- enzyme-adapter-react-16@1.11.2

Test runner environment

jest --config jestrc.json

jestrc.json

{
   "moduleFileExtensions": [
      "js"
   ],
   "moduleDirectories": [
      "source",
      "node_modules"
   ],  
   "moduleNameMapper": {
      "\\.(scss|css)$": "<rootDir>/__mocks__/styleMock.js",
      "\\.(png|svg)$": "<rootDir>/__mocks__/fileMock.js",
      "testUtils": "<rootDir>/testUtils"
   },
   "testPathIgnorePatterns": [
      "/node_modules/",
      "source/scripts/"
   ],
   "coveragePathIgnorePatterns": [
      "/node_modules/",
      "source/scripts/"
   ],
   "setupFiles": ["jest-canvas-mock", "jest-prop-type-error"],
   "setupFilesAfterEnv": ["<rootDir>/unittests.config.js"]
}

Your Environment

software version(s)
node 10.15.3
npm 6.4.1
Operating System Windows 10 Enterprise
@nicojs
Copy link
Member

nicojs commented May 31, 2019

Hmm interesting. Does a normal jest run with --findRelatedTests work as expected? This feature was added by @RobertBroersma and it seems to work and improve performance.

Stryker uses jests public API to set --findRelatedTests to the file that is mutated.

@jRichardeau
Copy link
Author

Yes as I said running jest with --findRelatedTests is ok.

If i do npx stryker run -m source/App.js, it's working for this file, but npx stryker run doesn't work for any file (looks like no test ran).

@andreadellacorte
Copy link

+1 on this, I had to disable this as before all my mutants were surviving as no tests were being run.

Putting my stryker config here in case it could help somebody in the future.

module.exports = function (config) {
  config.set({
    mutate: [ "src/*.js", "!src/update_triggers.js" ],
    mutator: "javascript",
    reporters: [ "html", "progress" ],
    htmlReporter: {
      baseDir: "stryker-reports/mutation/html"
    },
    testRunner: "jest",
    coverageAnalysis: "off",
    fileLogLevel: "debug",
    thresholds: {
      break: 70,
      high: 80,
      low: 60,
    },
    timeoutMS: 20000,
    timeoutFactor: 2,
    jest: {
      projectType: "custom",
      config: require('./jest.config.stryker.js'),
      enableFindRelatedTests: false,
    }
  });
};

@bartekleon
Copy link
Member

Is this issue still present?

@jRichardeau
Copy link
Author

Sorry but I don't know if it's still present, I'm not using stryker anymore because of some performance issues.

@jrfaller
Copy link

Hi,

According to some testing I made, this issue is present only on Windows

@BrandonHimes
Copy link

Not sure why this issue is closed. It's for sure still an issue. Happens on windows for me too.

@brazzy
Copy link

brazzy commented Jan 2, 2021

I can also confirm this issue is still present (using stryker 4.3.1 with jest 26.6.3 on Windows).

@amrsalama
Copy link

The problem is still there! This should be open again

@aubertaa
Copy link

Indeed still present on windows

@rob893
Copy link

rob893 commented Mar 20, 2021

I am also having this issue. Setting enableFindRelatedTests to false fixes it for me.

@nicojs
Copy link
Member

nicojs commented Mar 22, 2021

@rob893, @aubertaa and @amrsalama

I'm pretty sure this is all related to #2122 . Please see workaround(s) defined here: #2122 (comment)

Another workaround might be to use --inPlace mode.

TL;DR; This is an issue in jest: jestjs/jest#9728
Please upvote there 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests