Quantcast
Channel: "SyntaxError: Cannot use import statement outside a module" error while testing React Native project with Jest and @testing-library/react-native? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Aleksandr Galko for "SyntaxError: Cannot use import statement outside a module" error while testing React Native project with Jest and @testing-library/react-native?

$
0
0

It's working for me (react-native + expo + jest + @testing-library/react-native):

package.json

{  ..."scripts": {"start": "expo start","android": "expo start --android","ios": "expo start --ios","web": "expo start --web","test": "jest"  },"jest": {"preset": "jest-expo","transformIgnorePatterns": ["/node_modules/(?!react-native)/.+"    ],"transform": {"^.+\\.ts?$": "ts-jest","^.+\\.tsx?$": "ts-jest"    }  }...}

babel.config.js

module.exports = function(api) {  api.cache(true);  return {    presets: ['babel-preset-expo'],  };};

tsconfig.js

{"compilerOptions": {"jsx": "react","allowJs": true  },"extends": "expo/tsconfig.base"}

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>