1616
1717'use strict' ;
1818
19+ import path = require( 'path' ) ;
1920import * as _ from 'lodash' ;
2021import { expect } from 'chai' ;
2122
@@ -38,6 +39,8 @@ describe('Firestore', () => {
3839 + 'credentials. Must initialize the SDK with a certificate credential or application default '
3940 + 'credentials to use Cloud Firestore API.' ;
4041
42+ const mockServiceAccount = path . resolve ( __dirname , '../../resources/mock.key.json' ) ;
43+
4144 beforeEach ( ( ) => {
4245 appCredentials = process . env . GOOGLE_APPLICATION_CREDENTIALS ;
4346 gcloudProject = process . env . GCLOUD_PROJECT ;
@@ -104,6 +107,7 @@ describe('Firestore', () => {
104107 it ( 'should not throw given application default credentials without project ID' , ( ) => {
105108 // Project ID not set in the environment.
106109 delete process . env . GCLOUD_PROJECT ;
110+ process . env . GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount ;
107111 expect ( ( ) => {
108112 return new FirestoreService ( defaultCredentialApp ) ;
109113 } ) . not . to . throw ( ) ;
@@ -147,6 +151,7 @@ describe('Firestore', () => {
147151
148152 it ( 'should return a string when project ID is present in environment' , ( ) => {
149153 process . env . GCLOUD_PROJECT = 'env-project-id' ;
154+ process . env . GOOGLE_APPLICATION_CREDENTIALS = mockServiceAccount ;
150155 expect ( ( new FirestoreService ( defaultCredentialApp ) . client as any ) . projectId ) . to . equal ( 'env-project-id' ) ;
151156 } ) ;
152157 } ) ;
0 commit comments