我尝试使用jest with react-native卡住了这个错误。
"jest": {
"scriptPreprocessor": "node_modules/react-native/jestSupport/preprocessor.js",
"setupEnvScriptFile": "node_modules/react-native/jestSupport/env.js",
"testDirectoryName": "__jest__"
}
这是我对package.json
的开玩笑键react-native: 0.24.0
jest-cli: 12.0.2
babel-jest: 12.0.2
版本:
NodeJs
谢谢!
答案 0 :(得分:1)
相同,react-native v0.24,jest v12。
我已报告了一个问题:https://github.com/facebook/jest/issues/974
要修补此问题,您应该删除该行(请参阅问题)
node_modules/jestSupport
复制到您的项目jestSupport/env.js
jest.setMock('ErrorUtils', require('ErrorUtils'));
行require.requireActual('react-native/packager/react-packager/src/Resolver/polyfills/babelHelpers.js');
{
// ...
"jest": {
"setupEnvScriptFile": "<rootDir>/jestSupport/env.js",
// ...
}
}