English 中文(简体)
• 在错误卫士的ErrorHandler型号上使用Jest坠毁的土著试验:14
原标题:React Native Tests using Jest crashes on type ErrorHandler in error-guard.js:14

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

问题回答

UPDATE: i was able to fix this using the following regex: "transformIgnorePatterns": [ "node_modules/(?!(jest-)?react-native|@react-native|@react-navigation)" ]

如果任何人有任何建议或更好的方式来确立这一整体,那么毫不犹豫地增加如下内容! 感谢!





相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...