To reproduce:
Result:
FAIL tests/Intro-test.js (0.459s)
● Intro › it renders correctly
- TypeError: Cannot read property '_tag' of undefined
at ReactNativeBaseComponent.Mixin.mountComponent (node_modules/react/lib/ReactNativeBaseComponent.js:179:45)
at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
at ReactCompositeComponentMixin.performInitialMount (node_modules/react/lib/ReactCompositeComponent.js:397:34)
at ReactCompositeComponentMixin.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:262:21)
at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
at ReactCompositeComponentMixin.performInitialMount (node_modules/react/lib/ReactCompositeComponent.js:397:34)
at ReactCompositeComponentMixin.mountComponent (node_modules/react/lib/ReactCompositeComponent.js:262:21)
at Object.ReactReconciler.mountComponent (node_modules/react/lib/ReactReconciler.js:47:35)
at ReactMultiChild.Mixin.mountChildren (node_modules/react/lib/ReactMultiChild.js:242:44)
at ReactTestComponent.mountComponent (node_modules/react/lib/ReactTestRenderer.js:53:8)
Per https://facebook.github.io/jest/docs/tutorial-react-native.html#mock-native-modules-using-jest-mock, the workaround is to add
jest.mock('TextInput', () => 'TextInput');
to the beginning of your test.
We should provide a default mock for TextInput.
Fixed in https://github.com/facebook/jest/pull/1516 for Jest 15.
Most helpful comment
Per https://facebook.github.io/jest/docs/tutorial-react-native.html#mock-native-modules-using-jest-mock, the workaround is to add
jest.mock('TextInput', () => 'TextInput');
to the beginning of your test.