@@ -65,7 +65,8 @@ import {
65
65
ALT_PROJECT_ID ,
66
66
DEFAULT_PROJECT_ID ,
67
67
TARGET_DB_ID ,
68
- USE_EMULATOR
68
+ USE_EMULATOR ,
69
+ getEmulatorPort
69
70
} from '../util/settings' ;
70
71
71
72
// We're using 'as any' to pass invalid values to APIs for testing purposes.
@@ -209,10 +210,11 @@ apiDescribe('Validation:', persistence => {
209
210
'allows calling connectFirestoreEmulator() after use with same config' ,
210
211
async db => {
211
212
if ( USE_EMULATOR ) {
212
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 ) ;
213
+ const port = getEmulatorPort ( ) ;
214
+ connectFirestoreEmulator ( db , '127.0.0.1' , port ) ;
213
215
await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
214
216
expect ( ( ) =>
215
- connectFirestoreEmulator ( db , '127.0.0.1' , 9000 )
217
+ connectFirestoreEmulator ( db , '127.0.0.1' , port )
216
218
) . to . not . throw ( ) ;
217
219
}
218
220
}
@@ -225,10 +227,11 @@ apiDescribe('Validation:', persistence => {
225
227
if ( USE_EMULATOR ) {
226
228
const errorMsg =
227
229
'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 ) ;
229
232
await setDoc ( doc ( db , 'foo/bar' ) , { } ) ;
230
233
expect ( ( ) =>
231
- connectFirestoreEmulator ( db , '127.0.0.1' , 9001 )
234
+ connectFirestoreEmulator ( db , '127.0.0.1' , port + 1 )
232
235
) . to . throw ( errorMsg ) ;
233
236
}
234
237
}
0 commit comments