I am trying to write some unit-tests using the firebase-emulator. No matter what I do, it always gives me this error:
Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
describe('Cloud Functions', function() {
let myFunctions: any, adminInitStub: sinon.SinonStub<[options?: admin.AppOptions, name?: string], admin.app.App>;
const tester = funcTest();
before(async () => {
admin.initializeApp();
adminInitStub = sinon.stub(admin, "initializeApp");
myFunctions = await import("../src/index")
});
after(() => {
adminInitStub.restore();
tester.cleanup();
});
describe("dbOrderServiceOnCreated", () => {
it("should add snapshot successfully", async function() {
const wrapped = tester.wrap(myFunctions.dbOrderServiceOnCreated)
wrapped(serviceOrderSnap)
this.timeout(0);
// THIS IS THE PROBLEM
const value = await admin.firestore().collection(constants.collectionOrdersService).get();
return chai.assert.equal(value.size, 1);
})
})
})