MCPcopy Create free account
hub / github.com/firebase/firebase-functions-test / init

Method init

src/lifecycle.ts:37–71  ·  view source on GitHub ↗

Initialize the SDK.

(
    /** Firebase config values for initializing a Firebase app for your test code to
     * interact with (e.g. making database writes). It is recommended that you use
     * a project that is specifically for testing. If omitted, mock config values will
     * be used and your tests will not interact with a real Firebase app, and all Firebase
     * methods need to be stubbed, otherwise they will fail.
     */
    firebaseConfig?: AppOptions,
    /** Path to a service account key file to be used when initializing the Firebase app. */
    pathToServiceAccountKey?: string
  )

Source from the content-addressed store, hash-verified

35
36 /** Initialize the SDK. */
37 init(
38 /** Firebase config values for initializing a Firebase app for your test code to
39 * interact with (e.g. making database writes). It is recommended that you use
40 * a project that is specifically for testing. If omitted, mock config values will
41 * be used and your tests will not interact with a real Firebase app, and all Firebase
42 * methods need to be stubbed, otherwise they will fail.
43 */
44 firebaseConfig?: AppOptions,
45 /** Path to a service account key file to be used when initializing the Firebase app. */
46 pathToServiceAccountKey?: string
47 ) {
48 this._oldEnv = {
49 FIREBASE_CONFIG: process.env.FIREBASE_CONFIG,
50 GOOGLE_APPLICATION_CREDENTIALS:
51 process.env.GOOGLE_APPLICATION_CREDENTIALS,
52 GCLOUD_PROJECT: process.env.GCLOUD_PROJECT,
53 CLOUD_RUNTIME_CONFIG: process.env.CLOUD_RUNTIME_CONFIG,
54 };
55
56 if (isEmpty(firebaseConfig)) {
57 process.env.FIREBASE_CONFIG = JSON.stringify({
58 databaseURL: 'https://not-a-project.firebaseio.com',
59 storageBucket: 'not-a-project.appspot.com',
60 projectId: 'not-a-project',
61 });
62 } else {
63 process.env.FIREBASE_CONFIG = JSON.stringify(firebaseConfig);
64 if (pathToServiceAccountKey) {
65 process.env.GOOGLE_APPLICATION_CREDENTIALS = pathToServiceAccountKey;
66 }
67 }
68 process.env.GCLOUD_PROJECT = JSON.parse(
69 process.env.FIREBASE_CONFIG
70 ).projectId;
71 }
72
73 /** Complete clean up tasks. */
74 cleanup() {

Callers 6

index.tsFile · 0.80
testAppFunction · 0.80
lifecycle.spec.tsFile · 0.80
main.spec.tsFile · 0.80
app.spec.tsFile · 0.80
database.spec.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected