React native 如何模拟反应本机I18nManager

React native 如何模拟反应本机I18nManager,react-native,mocking,jestjs,react-native-router-flux,React Native,Mocking,Jestjs,React Native Router Flux,我正在试着在react native中运行笑话案例。我用它来导航。我的测试用例因此错误而失败 Test suite failed to run TypeError: Cannot read property 'isRTL' of undefined at Object.<anonymous> (node_modules/react-native-router-flux/dist/NavBar.js:286:44) at Object.<ano

我正在试着在react native中运行笑话案例。我用它来导航。我的测试用例因此错误而失败

Test suite failed to run

    TypeError: Cannot read property 'isRTL' of undefined

      at Object.<anonymous> (node_modules/react-native-router-flux/dist/NavBar.js:286:44)
      at Object.<anonymous> (node_modules/react-native-router-flux/dist/navigationStore.js:7:13)
      at Object.<anonymous> (node_modules/react-native-router-flux/dist/Reducer.js:74:36)

我把这个代码片段放在jest初始配置文件中,但出现了类似于I18nManager是只读的这样的错误。实际上,我使用的是正在运行的显式模块工厂,而不是jest的自动模拟功能

像这样

jest.mock('react-native', () => require('react-native-mock-render'), {
  virtual: true
})
当我浏览这个lib代码时,在mock中找不到I18nManager。因此,我分叉了那个repo,自己添加了I18nManager文件

jest.mock('react-native', () => require('react-native-mock-render'), {
  virtual: true
})