Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 意外标记,应为“预期”&引用;开玩笑+;天然酶_React Native_Jestjs - Fatal编程技术网

React native 意外标记,应为“预期”&引用;开玩笑+;天然酶

React native 意外标记,应为“预期”&引用;开玩笑+;天然酶,react-native,jestjs,React Native,Jestjs,我是第一次使用jest测试react native,这就是错误所在 测试失败/app.test.js ● 测试套件无法运行 SyntaxError: /Users/joyce/Projects/MamaOpe/mobileapp/node_modules/react-native/Libraries/polyfills/error-guard.js: Unexpected token, expected ";" (14:5) 12 | let _inGuard = 0; 13 | &g

我是第一次使用jest测试react native,这就是错误所在

测试失败/app.test.js ● 测试套件无法运行

SyntaxError: /Users/joyce/Projects/MamaOpe/mobileapp/node_modules/react-native/Libraries/polyfills/error-guard.js: Unexpected token, expected ";" (14:5)

  12 | let _inGuard = 0;
  13 |
> 14 | type ErrorHandler = (error: mixed, isFatal: boolean) => void;
     |      ^
  15 | type Fn<Args, Return> = (...Args) => Return;
  16 |
  17 | /**

  at Parser._raise (node_modules/@babel/parser/lib/index.js:742:17)
  at Parser.raiseWithData (node_modules/@babel/parser/lib/index.js:735:17)
  at Parser.raise (node_modules/@babel/parser/lib/index.js:729:17)
  at Parser.unexpected (node_modules/@babel/parser/lib/index.js:8779:16)
  at Parser.semicolon (node_modules/@babel/parser/lib/index.js:8761:40)
  at Parser.parseExpressionStatement (node_modules/@babel/parser/lib/index.js:11637:10)
  at Parser.parseStatementContent (node_modules/@babel/parser/lib/index.js:11238:19)
  at Parser.parseStatement (node_modules/@babel/parser/lib/index.js:11104:17)
  at Parser.parseBlockOrModuleBlockBody (node_modules/@babel/parser/lib/index.js:11679:25)
  at Parser.parseBlockBody (node_modules/@babel/parser/lib/index.js:11665:10)
这是我的jest.config.js

module.exports = {
 presets: ['@babel/preset-env'],
 plugins: ['@babel/plugin-proposal-class-properties'],
 };
module.exports = {
 preset: 'react-native',
 moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
 transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native)',
'node_modules/?!(react-navigation)',
 ],
  };

我做错了什么??该应用程序是使用react native cli not expo构建的

我知道这是一个旧版本,但我遇到了这个问题,因为我不在根目录中,因此运行jest会给出不正确的结果。

你是对的