首页 > 解决方案 > 如何在排毒测试期间模拟模块方法?

问题描述

我在 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)
  })

它不起作用,所以我想知道它是否可能?

标签: javascriptreact-nativedetox

解决方案


推荐阅读