File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
packages/rules-unit-testing/src/impl Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,14 @@ class RulesTestContextImpl implements RulesTestContext {
192
192
}
193
193
database ( databaseURL ?: string ) : firebase . database . Database {
194
194
assertEmulatorRunning ( this . emulators , 'database' ) ;
195
+ if ( ! databaseURL ) {
196
+ const url = makeUrl ( this . emulators . database , '' ) ;
197
+ // Make sure to set the namespace equal to projectId -- otherwise the RTDB SDK will by default
198
+ // use `${projectId}-default-rtdb`, which is treated as a different DB by the RTDB emulator
199
+ // (and thus WON'T apply any rules set for the `projectId` DB during initialization).
200
+ url . searchParams . append ( 'ns' , this . projectId ) ;
201
+ databaseURL = url . toString ( ) ;
202
+ }
195
203
const database = this . getApp ( ) . database ( databaseURL ) ;
196
204
database . useEmulator (
197
205
this . emulators . database . host ,
You can’t perform that action at this time.
0 commit comments