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

React enzyme adapter fails with symlinkNodeModules=true #1564

Closed
jRichardeau opened this issue May 28, 2019 · 7 comments
Closed

React enzyme adapter fails with symlinkNodeModules=true #1564

jRichardeau opened this issue May 28, 2019 · 7 comments

Comments

@jRichardeau
Copy link

Summary

I'm using stryker in a react project that uses enzyme with react adapter.

With the symlinkNodeModules option to true, enzyme initialization fails with this error :

Enzyme Internal Error: configured enzyme adapter did not inherit from the EnzymeAdapter base class

 > Enzyme.configure({ adapter: new Adapter() });

Thank you

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
      }
   });
};
}

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

# Test command

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"]
}

unitests.config.json

import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

Enzyme.configure({ adapter: new Adapter() });

Your Environment

software version(s)
node 10.15.3
npm 6.4.1
Operating System Windows 10 Enterprise

Add stryker.log

stryker.log

@nicojs
Copy link
Member

nicojs commented May 29, 2019

Interesting, so it does work with symlinkNodeModules set to false?

I think this has something to do with Enzyme or jest not being able to handle symlinked node_modules. #717 seems to have the same issue, so it might be fixed when jestjs/jest#5356 gets implemented.

If it does work with setting symlinkNodeModules to false, how would you suggest improving the documentation for that? I guess you did quite a lot of searching to find that option 😅

@jRichardeau
Copy link
Author

If it does work with setting symlinkNodeModules to false, how would you suggest improving the documentation for that? I guess you did quite a lot of searching to find that option 😅

Yes I searched for a little while 😄, and yes it does work with symlinkNodeModules to false.
I think it could be documented on the jest plugin readme in the symlinkNodeModules option ?

You think the issue comes from jest ? Not enzyme ?
And last question, does set symlinkNodeModules to false change something for performance ?

@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.

@bartekleon
Copy link
Member

try Stryker 4.0! its much faster now :)

@simondel
Copy link
Member

I'm closing this issue for now.

@nicojs
Copy link
Member

nicojs commented Jan 25, 2021

You can also use the new --inPlace mode, new since Stryker 4.4. Closing this issue for now, please open a new one if this problem persists.

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

4 participants