sbatson5 / firestore-jest-mock

Jest Helper library for mocking Cloud Firestore
https://www.npmjs.com/package/firestore-jest-mock
177 stars 58 forks source link

Firebase Auth module has a different structure with Firebase-Admin Auth module #108

Open johnkingzy opened 3 years ago

johnkingzy commented 3 years ago

Description

You all did a great job with mocking two modules which are

KUDOS 👍 🏆

However, there is an assumption that the Auth module in the firebase module would be the same as the Auth module in firebase-admin but they are different i.e with different methods and properties

For more clarity: This is the Auth module for Firebase Admin This is the Auth module for Firebase

if you scroll to methods, you will see that the method list is different.

Steps to reproduce

Try to use the auth module from firebase-admin, e.g

import * as admin from 'firebase-admin';
admin.initializeApp();

const auth = admin.auth();

auth.createUser({ email: 'test@example.com', password: 'password', displayName: 'john doe' })

Expected result

Actual result

TypeError: firebase_1.auth.createUser is not a function

Here is a link to a possible workaround solution https://gist.github.com/johnkingzy/9097b5b65fc8a472ed51a35d7a0aba45 TLDR: I redefined the FakeAuth class to match the module structure for firebase-admin

Environment