Воспроизвести:
Результат:
FAIL tests /Intro-test.js (0.459s)
● Вступление ›отображается правильно.
- TypeError: невозможно прочитать свойство _tag из undefined
в ReactNativeBaseComponent.Mixin.mountComponent (node_modules / react / lib / ReactNativeBaseComponent.js: 179: 45)
в Object.ReactReconciler.mountComponent (node_modules / react / lib / ReactReconciler.js: 47: 35)
в ReactCompositeComponentMixin.performInitialMount (node_modules / react / lib / ReactCompositeComponent.js: 397: 34)
в ReactCompositeComponentMixin.mountComponent (node_modules / react / lib / ReactCompositeComponent.js: 262: 21)
в Object.ReactReconciler.mountComponent (node_modules / react / lib / ReactReconciler.js: 47: 35)
в ReactCompositeComponentMixin.performInitialMount (node_modules / react / lib / ReactCompositeComponent.js: 397: 34)
в ReactCompositeComponentMixin.mountComponent (node_modules / react / lib / ReactCompositeComponent.js: 262: 21)
в Object.ReactReconciler.mountComponent (node_modules / react / lib / ReactReconciler.js: 47: 35)
в ReactMultiChild.Mixin.mountChildren (node_modules / response / lib / ReactMultiChild.js: 242: 44)
в ReactTestComponent.mountComponent (node_modules / react / lib / ReactTestRenderer.js: 53: 8)
Согласно https://facebook.github.io/jest/docs/tutorial-react-native.html#mock -native-modules-using-jest-mock обходным путем является добавление
jest.mock('TextInput', () => 'TextInput');
к началу вашего теста.
Мы должны предоставить макет по умолчанию для TextInput.
Исправлено в https://github.com/facebook/jest/pull/1516 для Jest 15.
Самый полезный комментарий
Согласно https://facebook.github.io/jest/docs/tutorial-react-native.html#mock -native-modules-using-jest-mock обходным путем является добавление
jest.mock('TextInput', () => 'TextInput');
к началу вашего теста.