I have written a function, that does create a document in firestore. Very basic snippet of the function:
await db.collection(VERFIY_CODES_PATH).doc().set({
user: uid,
code: result,
});
The problem is when I run my tests, this function actually creates real firestore documents. Is there a way of disabling that? My test looks like this:
import "dotenv/config";
import * as functions from "firebase-functions-test";
import * as path from "path";
import { anyContext, emptyData, emptyContext, anyUsername } from "./helpers/testConstants";
import { https } from "firebase-functions/v1";
import Message from "../src/types/message";
import getError from "./helpers/helperFunctions";
const projectConfig = {
projectId: "flowus-app-dev",
databaseURL: process.env.DATABASE_URL,
};
const testEnv = functions(projectConfig, path.resolve("./flowus-app-dev-fb-admin-sdk-key.json"));
import { verify } from "../src";
describe('Testing "verification"', () => {
it("test verification function works", async () => {
const data = {
locale: "en",
userName: anyUsername,
};
const result: Message = await testEnv.wrap(verify)(data, anyContext);
expect(result.code).toBe(200);
expect(result.message.length).toBe(6);
});
});
Any Ideas on how to fix this issue ?