javascript - 如何在排毒测试期间模拟模块方法?
问题描述
我在 detox e2e 测试期间尝试模拟一个模块:
beforeEach(async () => {
function mockFunctions() {
const original = require.requireActual('react-native-device-info');
return {
...original,
getDeviceCountry: jest.fn(() => {
return 'DE'
})
}
}
await jest.mock('react-native-device-info', () => mockFunctions)
})
它不起作用,所以我想知道它是否可能?
解决方案
推荐阅读
- pygame - AttributeError:“pygame.Surface”对象没有属性“get_rect”
- c# - 在 C# 中使用字母和数字 (code="BC1") 属性对 XML 进行排序
- python - Pygame rect.center 属性
- c# - 有没有一种简单的方法可以将 CSV 文件中记录的行号映射到 POCO?
- c# - 如何从 dotnet build 命令获取警告
- python - 无法将带有诗歌的 Python 工件发布到 Google 工件注册表,因为“HTTP 错误 413:请求实体太大”
- c++ - 以特定格式验证 C++ 用户输入
- r - 如何将日期更改为 R 中的连续数字?
- angularjs - 赛普拉斯:在日历弹出窗口中找不到元素
- python - Django - 当用户提交表单时,会创建表,但表之间的连接不是