【发布时间】:2017-12-09 10:44:47
【问题描述】:
我正在尝试模拟一个带有 react-native (不是 3rd 方模块) 的模块,例如 LayoutAnimation:
import * as RN from 'react-native'
RN.LayoutAnimation = jest.fn()
但测试失败:
TypeError: Cannot read property 'decelerationRate' of undefined
at Object.<anonymous> (node_modules/react-native/Libraries/Components/WebView/WebView.ios.js:555:3254)
at Object.get WebView [as WebView] (node_modules/react-native/Libraries/react-native/react-native-implementation.js:73:22)
是否有任何其他方法可以模拟/存根 RN 模块,例如 LayoutAnimation 或任何其他 react-native(不是第 3 方)模块?
【问题讨论】:
标签: react-native jestjs