Skip to content

"Can't determine Firebase Database URL." when initialize Admin SDK #171

Open
@ASE55471

Description

@ASE55471

Version info

**firebase-functions-test:"^2.4.0"

**firebase-functions:"^3.23.0"

**firebase-admin:"^11.0.1"

Test case

function code

import { https } from 'firebase-functions';
import { Timestamp } from 'firebase-admin/firestore';
import * as admin from 'firebase-admin';
admin.initializeApp();

let defaultDatabase = admin.database();
let defaultFirestore = admin.firestore();

test code

import { test } from "@jest/globals";
import { functionF} from "../../src/functionF";
import firebaseFunctionsTest from "firebase-functions-test";

const {wrap , firestore} = firebaseFunctionsTest({
    projectId: 'project-id',
    storageBucket: 'project-id.appspot.com',
    databaseURL: "https://project-id-default-rtdb.asia-southeast1.firebasedatabase.app",
}, './serviceAccountkey.json');


describe('test1', () => {
    test('test', () => {
        const wrappedFunctionF = wrap(functionF);
        const snap = firestore.makeDocumentSnapshot({ foo: 'bar' }, 'document/path');
        wrappedFunctionF(snap);
    });
});

I tried fill databaseURL without "-default-rtdb" but still throw same error.

Relative StackOverflow question I asked: https://stackoverflow.com/questions/73657752/how-to-initialize-admin-sdk-with-firebase-functions-test

Expected behavior

Finish the test without error .

Actual behavior

It throw error.

    Can't determine Firebase Database URL.

      4 | admin.initializeApp();
      5 |
    > 6 | let defaultDatabase = admin.database();
        |                             ^
      7 | let defaultFirestore = admin.firestore();
      8 |

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions