RulesTestContext interface

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

Signature:

export interface RulesTestContext 

Methods

Method Description
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

Parameter Type Description
databaseURL string the 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

Parameter Type Description
settings firebase.firestore.Settings a 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

Parameter Type Description
bucketUrl string

Returns:

firebase.storage.Storage

a Storage instance configured to connect to the emulator