expo + typescript + testing-library/react-native

has anybody used testing-library/react-native to test the expo app?
I am following the steps defined by the library but I still have this error when I run my tests.

    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import './environment/muteWarnings.fx';

    SyntaxError: Cannot use import statement outside a module

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (node_modules/expo/src/Expo.ts:1:1)

and this is my jest configuration

const expoPreset = require('jest-expo/jest-preset')
const jestPreset = require('@testing-library/react-native/jest-preset')
module.exports = Object.assign({}, expoPreset, jestPreset)

Please provide the following:
Expo CLI 3.13.8 environment info:
OS: Linux 5.3 Ubuntu 18.04.4 LTS (Bionic Beaver)
Shell: 4.4.20 - /bin/bash
Node: 12.14.0 - ~/.nvm/versions/node/v12.14.0/bin/node
npm: 6.13.4 - ~/.nvm/versions/node/v12.14.0/bin/npm
expo: ^37.0.0 => 37.0.3
react: 16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz => 0.61.4
expo-cli: 3.13.8

Thanks in advance for any help

I’ve found the solution,

baically I had to use the @testing-library/react-native preset and extend it with the jest-expo preset content. To be honest still don’t know why it didn’t work with my previous solution.

module.exports = {
  preset: '@testing-library/react-native',
  haste: { defaultPlatform: 'ios', platforms: ['android', 'ios', 'native'] },
  transform: {
    '^.+\\.(js|ts|tsx)$': 'babel-jest',

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