Skip to content

firestore and auth mocks not complete on firebase-admin #159

@geraldosalazar16

Description

@geraldosalazar16

Summary

It looks like the mocks for firestore and auth (in tyhe firebase-admin) are outdated

Brief explanation of the feature.
When trying to mock firestore I got errors about recursiveDelete (in firestore) and getUserByEmail (in auth) not being functions. I added recursiveDelete on https://github.com/Upstatement/firestore-jest-mock/blob/master/mocks/firestore.js and getUserByEmail on https://github.com/Upstatement/firestore-jest-mock/blob/master/mocks/auth.js and my tests started passing

Basic example

getUserByEmail() { return Promise.resolve(mockGetUser(...arguments) || {}); }

recursiveDelete() { return Promise.resolve(); }
If the proposal involves a new or changed API, include a basic code example. Omit this section if it's not applicable.

Motivation

Why are we doing this? What use cases does it support? What is the expected outcome?
My workaround so far has being
`
import { FakeFirestore } from 'firestore-jest-mock/mocks/firestore';
Object.setPrototypeOf(FakeFirestore.prototype, {
...Object.getPrototypeOf(FakeFirestore.prototype),
recursiveDelete: jest.fn().mockResolvedValue('ok'),
});

import { FakeAuth } from 'firestore-jest-mock/mocks/auth';
Object.setPrototypeOf(FakeAuth.prototype, {
...Object.getPrototypeOf(FakeAuth.prototype),
getUserByEmail: jest
.fn()
.mockResolvedValue({ id: 'abc123', name: 'Homer Simpson' }),
});
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions