SteffeyDev / react-native-popover-view

A well-tested, adaptable, lightweight <Popover> component for react-native
MIT License
613 stars 92 forks source link

Facing "SyntaxError: Cannot use import statement outside a module" when trying to test #137

Closed Tatobarbosa closed 2 years ago

Tatobarbosa commented 2 years ago

Describe the bug I'm trying to implement this library to my app, but when i try to test, i'm having this issue: image

(It work properly on my device)

The strangest thing is that the other libraries I use in the app work without problems, only this one doesn't want to work.

Device/Setup Info:

jest.config.js:

module.exports = { preset: '@testing-library/react-native', moduleDirectories: ['node_modules', 'src'], transform: { '^.+\.js$': require.resolve('react-native/jest/preprocessor.js') }, testMatch: ['*/?(.)+(test).[jt]s?(x)'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], transformIgnorePatterns: [ 'node_modules/(?!((jest-)?react-native(-.*)?|' + 'react-navigation|' + 'react-native-config|' + 'react-native-linear-gradient|' + 'react-native-popup-menu|' + 'native-base-shoutem-theme|' + 'react-native-easy-grid|' + 'react-native-drawer|' + 'react-navigation-drawer|' + 'react-native-vector-icons|' + 'react-native-animatable|' + 'react-native-modal|' + '@react-native|' + '@react-native-community/datetimepicker|' + 'react-native-shimmer-placeholder|' + 'react-native-device-info|' + '@react-native-google-signin/google-signin|' + '@react-native-firebase/auth|' + '@react-native-firebase/app|' + 'rn-fetch-blob|' + 'react-native-adjust|' + 'react-native-reanimated|' + 'react-native-modal-datetime-picker|' + 'react-native-indicators|' + 'react-native-gesture-handler|' + 'react-native-screens|' + 'react-native-view-shot|' + 'smartlook-react-native-wrapper|' + 'react-native-snap-carousel|' + '@react-native-firebase/remote-config|' + 'query-string|' + 'react-native-background-timer|' + 'react-native-popover|' + 'react-native-safe-area-view|' + 'react-native-popover-view|' + 'react-native-popover-view-test|' + 'native-base)/)' ], setupFilesAfterEnv: [ '@testing-library/jest-native/extend-expect', './jest.setup.ts' ], coverageThreshold: { global: { branches: 57, functions: 68, lines: 68, statements: 68 } } };

babel.config.js

module.exports = { env: { production: { plugins: ['transform-remove-console'] } }, plugins: [ [ 'module-resolver', { alias: { '@api': './src/api', '@assets': './src/assets', '@factories': './src/factories', '@functions': './src/functions', '@mocks': './mocks', '@services': './src/services', '@hooks': './src/hooks', '@shared': './src/shared', '@templates': './src/templates', '@app-types': './src/types', '@views': './src/views', '@store': './src/store' }, extensions: ['.ts', '.tsx', '.js', '.png'], root: ['./src'] } ], 'jest-hoist' ], presets: ['module:metro-react-native-babel-preset'] };

SteffeyDev commented 2 years ago

@Tatobarbosa Sorry I didn't respond sooner, are you still having this issue?