jest-expo & expo-localization: SyntaxError: Cannot use import statement outside a module

Please provide the following:

  1. SDK Version: 47
  2. Platforms(Android/iOS/web/all): All

“jest”: “26.6.3”,
“jest-expo”: “^47.0.1”,

I’m getting the following error when running jest tests in my expo project:

SyntaxError: Cannot use import statement outside a module

The error points to the expo-localization library in node_modules:

/node_modules/axios/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import ExpoLocalization from './ExpoLocalization';

In the file under test, I’m importing expo-localization:

import * as Localization from 'expo-localization';

Here is my simple jest.config.js file:

module.exports = {
    preset: 'jest-expo',
    setupFilesAfterEnv: ["<rootDir>/setup-jest.ts"]
}

How can I get jest to play along with expo-localization?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.