I have a React Native application. When running my tests with Jest, it crashes with the following output:
<root-dir>/node_modules/@react-native/polyfills/error-guard.js:14
type ErrorHandler = (error: mixed, isFatal: boolean) => void;
^^^^^^^^^^^^
SyntaxError: Unexpected identifier ErrorHandler
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
at Object.<anonymous> (node_modules/react-native/jest/setup.js:402:6)
I m using jest ^29.2.1
, 在此,在我的 Package.json
档案中,我有“jest”物体:
"jest": {
"preset": "react-native",
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native)",
]
}
这里还有我的<代码>babel.config.js文档:
module.exports = {
presets: [ module:metro-react-native-babel-preset ],
};
请注意,我的测试套件( test__
, 夹)仅载有缺省评估试卷。
任何关于如何解决这一问题的想法? 我在其他职位上看到了几个解决办法,其中包括:>node_modules/(?!(jest-)?react-native : ́react-native-native----- Commun@react-navigation”
或<>/node_modules/(?!(react-n> > > > >transIgnorePatterns”/code within my 。