Code Bug Fix: Unexpected token, expected “;” jest + enzyme in react native

Original Source Link

I am my first test in react native using jest and this is the error

FAIL tests/app.test.js
● Test suite failed to run

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)

this is my babel.config.js

module.exports = {
 presets: ['@babel/preset-env'],
 plugins: ['@babel/plugin-proposal-class-properties'],
 };

this is my jest.config.js

module.exports = {
 preset: 'react-native',
 moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
 transformIgnorePatterns: [
'node_modules/(?!(jest-)?react-native)',
'node_modules/?!(react-navigation)',
 ],
  };

what am I doing wrong?? the app is built with react native cli not expo

Tagged : /

Leave a Reply

Your email address will not be published. Required fields are marked *