react-native - 模拟反应导航共享元素的正确方法
问题描述
SharedElement
我想通过从 react-navigation-shared-element获取与组件相关的错误来运行我的测试
我的模拟是这样的:
jest.mock('react-native-shared-element', () => {
return () => ({});
});
jest.mock('react-navigation-shared-element', () => {
return () => ({
createSharedElementStackNavigator: jest.fn(),
});
});
当我运行测试时:
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
解决方案
推荐阅读
- excel - 如何在 Excel 中对 2 小时之间发生的值求和
- javascript - 从 API 请求中删除空查询字符串的最佳方法
- javascript - 将回调函数传递给路由器中的模板
- javascript - 单击按钮时使用 Ajax 发送 POST 请求
- c# - Newtonsoft 反序列化不会将字符串转换为 DateTime
- java - Anylogic Experiment 使用不同的范围参数卡住,但在自由参数中工作正常
- ruby-on-rails - # 未定义的方法`street'
- regex - 使用 sed,在不同长度的单词周围加上引号
- python - 如何有一个特定的子命令需要带有 argparse 的标志?
- javascript - 在Angular2+中设置日期的输入格式