Jest issue - ReactElement.js: Failed to get metadata layout

I have a very simple test

/** @jsx React.DOM */
var store = require('../simpleStore');
var TestUtils = require('react/addons').addons.TestUtils;

describe("my tests",function(){
  it('simple test',function(){
     var x=10,
        y=20;
     expect(x).not.toBe(y);
  })
})

The test works fine until I require TestUtils. At that moment, when I add a link to node_module, I start to see errors below

Using Jest CLI v0.8.0, jasmine1
FAIL  build/stores/__tests__/simple-test.js

● Runtime Error

Error: ../stores/__tests__/simple-test.js:
../../node_modules/react/addons.js:
../../node_modules/react/lib/ReactWithAddons.js:
../../node_modules/react/lib/LinkedStateMixin.js:
../../node_modules/react/lib/ReactLink.js:
../../node_modules/react/lib/React.js:
../../node_modules/react/lib/ReactDOM.js:
../../node_modules/react/lib/ReactDOMTextComponent.js:
../../node_modules/react/lib/ReactComponentBrowserEnvironment.js:
../../node_modules/react/lib/ReactDOMIDOperations.js:
../../node_modules/react/lib/ReactMount.js:
../../node_modules/react/lib/ReactElement.js: Failed to get mock metadata:
../../node_modules/react/lib/canDefineProperty.js
npm ERR! Test failed.  See above for more details.

I am sure that many people use a joke and I am missing something stupid. Eliminate any ideas to fix this problem?

+4
source share
1 answer

Try disabling the mockery for the reaction - in the jset configuration in package.json:

"unmockedModulePathPatterns": [
  "<rootDir>/node_modules/react",
  "<rootDir>/node_modules/fbjs"
]
+5
source

Source: https://habr.com/ru/post/1617795/


All Articles