使用笑话进行单元测试时遇到问题:
永久违反:本机模块不能为空。
at invariant (node_modules/fbjs/lib/invariant.js:42:15) at new NativeEventEmitter (node_modules/react-native/Libraries/EventEmitter/NativeEventEmitter.js:35:7) at Object.<anonymous> (node_modules/react-native-google-analytics-bridge/src/Helpers/FunctionCallTagHandler/index.io
s.js:16:37) 在对象。 (node_modules / react-native-google-analytics-bridge / src / GoogleTagManager.js:2:1)
答案 0 :(得分:0)
我之前也遇到过同样的问题。可以建议解决方法。 react-native-google-analytics-bridge
仅在iOS上会发生此问题,因此您可以将玩笑的默认平台切换为Android。
在您的package.json
"jest": {
"preset": "react-native",
"haste": {
"defaultPlatform": "android",
"platforms": [
"android",
"ios"
],
"providesModuleNodeModules": [
"react",
"react-native"
]
}
}