@@ -65,7 +65,8 @@ import {
6565 ALT_PROJECT_ID ,
6666 DEFAULT_PROJECT_ID ,
6767 TARGET_DB_ID ,
68- USE_EMULATOR
68+ USE_EMULATOR ,
69+ getEmulatorPort
6970} from '../util/settings' ;
7071
7172// We're using 'as any' to pass invalid values to APIs for testing purposes.
@@ -209,10 +210,11 @@ apiDescribe('Validation:', persistence => {
209210 'allows calling connectFirestoreEmulator() after use with same config' ,
210211 async db => {
211212 if ( USE_EMULATOR ) {
212- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
213+ const port = getEmulatorPort ( ) ;
214+ connectFirestoreEmulator ( db , '127.0.0.1' , port ) ;
213215 await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
214216 expect ( ( ) =>
215- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 )
217+ connectFirestoreEmulator ( db , '127.0.0.1' , port )
216218 ) . to . not . throw ( ) ;
217219 }
218220 }
@@ -225,10 +227,11 @@ apiDescribe('Validation:', persistence => {
225227 if ( USE_EMULATOR ) {
226228 const errorMsg =
227229 'Firestore has already been started and its settings can no longer be changed.' ;
228- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
230+ const port = getEmulatorPort ( ) ;
231+ connectFirestoreEmulator ( db , '127.0.0.1' , port ) ;
229232 await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
230233 expect ( ( ) =>
231- connectFirestoreEmulator ( db , '127.0.0.1' , 9001 )
234+ connectFirestoreEmulator ( db , '127.0.0.1' , port + 1 )
232235 ) . to . throw ( errorMsg ) ;
233236 }
234237 }
0 commit comments