Я использую NumericInput , и он отлично работает, когда я запускаю приложение на своем устройстве.
Однако, когда я запускаю jest
, я получаю всевозможные ошибки:
TypeError: Cannot read property 'default' of undefined
at new Icon (node_modules/react-native-vector-icons/lib/create-icon-set.js:42:389)
at constructClassInstance (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:3435:18)
at updateClassComponent (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:6606:5)
at beginWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:7563:16)
at performUnitOfWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11234:12)
at workLoop (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11266:24)
at renderRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:11349:7)
at performWorkOnRoot (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:12237:7)
at performWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:12149:7)
at performSyncWork (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:12123:3)
и
console.error node_modules/react-test-renderer/cjs/react-test-renderer.development.js:9036
The above error occurred in the <Icon> component:
in Icon (at NumericInput.js:226)
in View (created by View)
in View (at createAnimatedComponent.js:151)
in AnimatedComponent (at TouchableOpacity.js:282)
in TouchableOpacity (at Button.js:18)
in Button (at NumericInput.js:225)
in View (created by View)
in View (at NumericInput.js:224)
in NumericInput
in View (created by View)
in View
in View (created by View)
in View (at ScrollViewMock.js:29)
in RCTScrollView (created by _class)
in _class (at ScrollViewMock.js:27)
in ScrollViewMock (created by App)
in App
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://.../react-error-boundaries to learn more about error boundaries.
Первый вопрос : Это нормально?
Второй вопрос : Если это так,как мне издеваться NumericInput
?
Следуя этому руководству , мне кажется, мне нужно сделать:
jest.mock('react-native-numeric-input', () => 'NumericInput');
Но это не работает.Я также попробовал:
jest.mock('react-native-vector-icons', () => 'Icon');
Безуспешно.
Что здесь происходит o_0?
Приветствия!