RulesTestContext interface

A test context that represents a client. Can be used to access emulators for rules unit testing.

Signature:

exportinterfaceRulesTestContext

Methods

MethodDescription
database(databaseURL)Get a Database instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).See: Database
firestore(settings)Get a Firestore instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).See: Firestore
storage(bucketUrl)Get a FirebaseStorage instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).See: FirebaseStorage

RulesTestContext.database()

Get a Database instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).

See: Database

Signature:

database(databaseURL?:string):firebase.database.Database;

Parameters

ParameterTypeDescription
databaseURLstringthe URL of the Realtime Database instance. If specified, returns an instance for an emulated version of the namespace with parameters extracted from URL

Returns:

firebase.database.Database

a Database instance configured to connect to the emulator. It never connects to production even if a production databaseURL is specified

RulesTestContext.firestore()

Get a Firestore instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).

See: Firestore

Signature:

firestore(settings?:firebase.firestore.Settings):firebase.firestore.Firestore;

Parameters

ParameterTypeDescription
settingsfirebase.firestore.Settingsa settings object to configure the Firestore instance

Returns:

firebase.firestore.Firestore

a Firestore instance configured to connect to the emulator

RulesTestContext.storage()

Get a FirebaseStorage instance for this test context. The returned Firebase JS Client SDK instance can be used with the client SDK APIs (v9 modular or v9 compat).

See: FirebaseStorage

Signature:

storage(bucketUrl?:string):firebase.storage.Storage;

Parameters

ParameterTypeDescription
bucketUrlstring

Returns:

firebase.storage.Storage

a Storage instance configured to connect to the emulator