Skip to content

initializeApp does not return functions method #155

@crutchcorn

Description

@crutchcorn

The code usage I'm having looks like:

export const firebaseApp = firebase.initializeApp(firebaseConfig);
// Used for creating child accounts, primarily
export const firebaseSecondaryApp = firebase.initializeApp(firebaseConfig, 'Secondary');
export const firebaseAuth = firebaseApp.auth();
export const firebaseSecondaryAuth = firebaseSecondaryApp.auth();
export const firebaseDb = firebaseApp.database();
export const firebaseFunc = firebaseApp.functions();

With my mocks just looking like this:

jest.mock('firebase/auth', () => ({}));
jest.mock('firebase/functions', () => ({}));
jest.mock('firebase/database', () => ({}));
jest.mock('firebase/app', () => {
    const firebaseMock = require('firebase-mock');

    const mockDatabase = new firebaseMock.MockFirebase();
    const mockAuth = new firebaseMock.MockFirebase();
    const mockSDK = new firebaseMock.MockFirebaseSdk((path: any) => {
        return path ? mockDatabase.child(path) : mockDatabase;
    }, () => {
        return mockAuth;
    });

    const firebaseApp = mockSDK.initializeApp();

    return mockSDK;
});

However my code gives me errors as there is no functions method on the return value for initializeApp

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