【问题标题】:Firebase getReactNativePersistence not working during jest testsFirebase getReactNativePersistence 在开玩笑测试期间不起作用
【发布时间】:2022-08-17 02:49:50
【问题描述】:

当我测试我的 React Native 应用程序时,该应用程序取消了我的 firebase 配置文件

const auth = initializeAuth(app, {
    persistence: getReactNativePersistence(AsyncStorage),
});

我收到错误消息:Cannot find module \'@firebase/auth/react-native\' from \'node_modules/firebase/auth/react-native/dist/index.cjs.js\'

该应用程序在运行时运行良好,但在测试期间似乎不起作用。

关于这个错误可能是由什么引起的任何想法?

    标签: firebase react-native firebase-authentication asyncstorage


    【解决方案1】:

    今天早上我遇到了同样的问题。你解决了吗?

    我发现在嘲笑名为 @firebase/auth/react-native.js 的目录并导出命名函数 getReactNativePersistence 为我解决了这个问题(现在)。此时它只是一个虚拟函数,但我的测试运行。

    __mocks__/@firebase/auth/react-native.js
    
    export const getReactNativePersistence = () => {
      return;
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-11
      • 2018-04-05
      • 1970-01-01
      • 1970-01-01
      • 2016-11-11
      • 2020-07-04
      • 1970-01-01
      • 2021-01-01
      相关资源
      最近更新 更多