Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

792
Views
SyntaxError - node_modules/react-native/Libraries/polyfills/error-guard.js: Missing semicolon. (14:4) on running jest in react native library

I'm trying to setup jest for a react native library but I'm getting the below error

SyntaxError: react-native/Libraries/polyfills/error-guard.js: Missing semicolon. (14:4)

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

react-native version : 0.61.5

app.js

import { Dimensions } from 'react-native';

function sum(a, b) {
    return a + b;
}
module.exports = sum;

app.test.js

const sum = require('./app');

test('adds 1 + 2 to equal 3', () => {
  expect(sum(1, 2)).toBe(3);
});

jest.config.js

module.exports ={
    preset : 'react-native',
    transformIgnorePatterns: [
        '/node_modules/(?!(@react-native|react-native)/).*/'
    ]
}

.babelrc

{
    "presets": ["react-native"]
}

I tried various solutions suggested like adding transformIgnorePatterns but to no avail. can someone help me here ?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

It worked for me after I changed the .babelrc file to babel.config.js.

about 4 years ago · Juan Pablo Isaza Report

0

It also worked for me after I changed the .babelrc file to babel.config.js

module.exports = {
    presets: ['module:metro-react-native-babel-preset'],
};

package.json

"react": "17.0.2",
"react-native": "0.67.4",
[...]
"@babel/core": "7.18.0",
about 4 years ago · Juan Pablo Isaza Report

0

I could finally fix this problem after a long struggle:

As Daniel said in the answer above we need to change the .babelrc file to babel.config.js. In addition to that we have to follow the below steps:

  1. Define presets: ['module:metro-react-native-babel-preset'] in the babel.config.js file.
  2. Add following packages to the package.json file: "@testing-library/jest-native": "^4.0.5", and "babel-plugin-transform-class-properties": "^6.24.1"
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!