首页 > 解决方案 > Firebase 远程配置不适用于单元测试中的 NodeJS

问题描述

我创建了一个使用 Firebase 远程配置的函数。一切正常npm run start。但是当我尝试运行所有单元测试用例时,它不再起作用了。以下是我用来导入库的代码:

// This import loads the firebase namespace along with all its type information.
import * as firebase from 'firebase/app';

// These imports load individual services into the firebase namespace.
import 'firebase/remote-config';

但是,当我尝试使用 command 运行单元测试时npm run test。它通过一个异常:

Test suite failed to run

(node:18099) UnhandledPromiseRejectionWarning: ReferenceError: indexedDB is not defined
(node:18099) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

这是屏幕截图: 在此处输入图像描述

你们对如何解决这个问题有任何想法吗?谢谢。

标签: node.jsreactjsfirebasefirebase-remote-config

解决方案


推荐阅读