Tell us which versions you are using:
Test suite should NOT fail to run
Test suite failed to run
Invariant Violation: Native module cannot be null.
at invariant (node_modules/fbjs/lib/invariant.js:44:15)
at Linking.NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:32:1)
at new Linking (node_modules/react-native/Libraries/Linking/Linking.js:119:141)
at Object.<anonymous> (node_modules/react-native/Libraries/Linking/Linking.js:191:16)
at Object.get Linking [as Linking] (node_modules/react-native/Libraries/react-native/react-native.js:90:22)
at Object.<anonymous> (node_modules/react-native-experimental-navigation/NavigationRootContainer.js:15:36)
Explicit line breaking test: import { Actions } from 'react-native-router-flux' (when deleted and replaced with arrow function - doesn't happen:
<TouchableNativeFeedback onPress={Actions.SecondScene}>
into
<TouchableNativeFeedback onPress={() => {}}>
Test itself:
import 'react-native'
import React from 'react'
import FirstScene from '../index'
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer'
it('renders correctly', () => {
const tree = renderer.create(
<FirstScene />
)
expect(tree).toBeDefined()
})
Actions,jest or npm run testThank you for awesome library :) Reporting this issue because I care about growth and well-being of it.
For all struggling with this issue, here's the solution:
__mock__ folder in ur app directory.react-native-router-flux.jsexport const Actions = {} and save.Jest will use provided mock and this will resolve the issue, therefore it will be sufficient for all cases where you imported Actions - in any child etc.
I don't know Jest very well but I image this could be potentially the place for stubs and spys :)
Most helpful comment
For all struggling with this issue, here's the solution:
__mock__folder in urappdirectory.react-native-router-flux.jsexport const Actions = {}and save.Jest will use provided mock and this will resolve the issue, therefore it will be sufficient for all cases where you imported
Actions- in any child etc.I don't know Jest very well but I image this could be potentially the place for
stubsandspys:)