Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6313

Jest: test fails with "SyntaxError: Cannot use import statement outside a module" React native

$
0
0

I'm trying to run a test but it failes with this error:enter image description herepackage.json

..."jest": {"preset": "react-native"  },...

tsconfig.json

{"compilerOptions": {"allowJs": true,"allowSyntheticDefaultImports": true,"esModuleInterop": true,"isolatedModules": true,"jsx": "react-native","lib": ["es6"],"moduleResolution": "node","noEmit": true,"strict": true,"target": "esnext",  },"exclude": ["node_modules","babel.config.js","metro.config.js","jest.config.js"  ]}

jest.config.js

module.exports = {  preset: 'react-native',  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],  transformIgnorePatterns: ['@react-native-firebase/admob'], };

bable.config.js

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

Already tried few things but none of them worked.Let me know if something is missing and I'll edit the post.Thanks!


Viewing all articles
Browse latest Browse all 6313

Trending Articles



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