mercredi 19 juin 2019

_firebase.collections.collection.get.mockResolvedValue is not a function on vue

I'm trying to test the firebase collections, but I'm getting the following error:

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

I'm using jest, and already tried using the following forms: collections.contacts.get.mockResolvedValue(() => Promise.resolve([]));

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

but none of them worked

On the 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")
};


The complete output of npm run test:unit:

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

Anyone has an idea of how to solve this problem?

Aucun commentaire:

Enregistrer un commentaire