I can't run my tests even using your jest.setup approach (Super expression must either be null or a function) #5605
Answered
by
mikehardy
ulises-castro
asked this question in
Q&A
-
I'm using your Jest.Setup in order to mock up the react-native stuff, however I can't solve this issue yet. jest.config.js file module.exports = {
preset: "react-native",
setupFiles: ['./jest.setup.js'],
transform: {},
"transformIgnorePatterns": [
"node_modules/(?!(@react-native|react-native|react-native-vector-icons|react-native-material-kit|@invertase|react-native-keyboard-aware-scrollview|react-native-easy-toast|react-native-image-picker|react-native-webview|react-native-background-upload|@react-native-firebase)/)"
],
"setupFilesAfterEnv": [
"@testing-library/jest-native/extend-expect"
]
} jest.setup.js file import * as ReactNative from 'react-native';
jest.doMock('react-native', () => {
return Object.setPrototypeOf(
{
Platform: {
OS: 'android',
select: () => { },
},
NativeModules: {
...ReactNative.NativeModules,
RNFBAppModule: {
NATIVE_FIREBASE_APPS: [
{
appConfig: {
name: '[DEFAULT]',
},
options: {},
},
{
appConfig: {
name: 'secondaryFromNative',
},
options: {},
},
],
addListener: jest.fn(),
eventsAddListener: jest.fn(),
eventsNotifyReady: jest.fn(),
},
RNFBAuthModule: {
APP_LANGUAGE: {
'[DEFAULT]': 'en-US',
},
APP_USER: {
'[DEFAULT]': 'jestUser',
},
addAuthStateListener: jest.fn(),
addIdTokenListener: jest.fn(),
useEmulator: jest.fn(),
},
RNFBCrashlyticsModule: {},
RNFBDatabaseModule: {
on: jest.fn(),
useEmulator: jest.fn(),
},
RNFBFirestoreModule: {
settings: jest.fn(),
documentSet: jest.fn(),
},
RNFBPerfModule: {},
RNFBStorageModule: {
useEmulator: jest.fn(),
},
},
},
ReactNative,
);
}); `
any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
mikehardy
Aug 19, 2021
Replies: 1 comment
-
Sorry, this is project-specific. All I can offer is that you may clone the repo, run |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
andersonaddo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry, this is project-specific. All I can offer is that you may clone the repo, run
yarn && yarn tests:jest
and it works.