Stryker: React enzyme adapter fails with symlinkNodeModules=true

Created on 28 May 2019  路  6Comments  路  Source: stryker-mutator/stryker

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/[email protected]
| +-- @stryker-mutator/[email protected]
| +-- @stryker-mutator/[email protected]
+-- @stryker-mutator/[email protected]
| +-- @stryker-mutator/[email protected] deduped
| +-- @stryker-mutator/[email protected] deduped
+-- @stryker-mutator/[email protected]
| +-- @stryker-mutator/[email protected] deduped
+-- @stryker-mutator/[email protected]
| +-- @stryker-mutator/[email protected] deduped
+-- [email protected]
+-- [email protected]
+-- [email protected]

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


All 6 comments

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 https://github.com/facebook/jest/issues/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 馃槄

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 ?

Is this issue still present?

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

try Stryker 4.0! its much faster now :)

I'm closing this issue for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

trollepierre picture trollepierre  路  18Comments

Lakitna picture Lakitna  路  42Comments

wolf-off picture wolf-off  路  18Comments

kmdrGroch picture kmdrGroch  路  19Comments

VincentLanglet picture VincentLanglet  路  31Comments