_firebase.collections.collection.get.mockResolvedValue不是vue上的函数

时间:2019-06-19 12:43:54

标签: unit-testing vue.js testing jestjs

我正在尝试测试Firebase集合,但出现以下错误:

_firebase.collections.contacts.get.mockResolvedValue is not a function

我正在使用笑话,并且已经尝试使用以下形式: collections.contacts.get.mockResolvedValue(() => Promise.resolve([]));

collections.contacts.get.mockResolvedValue(Promise.resolve([]);

但没有一个起作用

在test.spec.js上

import { collections } from "@/lib/firebase.js";
jest.mock("@/lib/firebase.js");
collections.contacts.get.mockResolvedValue([]);

@ / lib / firebase.js

import { firebase } from "@firebase/app";
import "@firebase/firestore";

const firebaseApp = firebase.initializeApp({
   // my api keys
});

export const db = firebaseApp.firestore();

export const collections = {
  contacts: db.collection("contacts")
};

npm的完整输出运行test:unit:

TypeError: _firebase.collections.contacts.get.mockResolvedValue is not a function

有人知道如何解决这个问题吗?

0 个答案:

没有答案