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
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
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).
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).
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).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["A test context that represents a client. Can be used to access emulators for rules unit testing.\n\n\u003cbr /\u003e\n\n**Signature:** \n\n export interface RulesTestContext \n\nMethods\n\n| Method | Description |\n|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [database(databaseURL)](./rules-unit-testing.rulestestcontext.md#rulestestcontextdatabase) | Get a [Database](/docs/reference/js/database.database#database_class) 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](/docs/reference/js/database.database#database_class) |\n| [firestore(settings)](./rules-unit-testing.rulestestcontext.md#rulestestcontextfirestore) | Get a [Firestore](/docs/reference/js/firestore_.firestore#firestore_class) 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](/docs/reference/js/firestore_.firestore#firestore_class) |\n| [storage(bucketUrl)](./rules-unit-testing.rulestestcontext.md#rulestestcontextstorage) | Get a [FirebaseStorage](/docs/reference/js/storage.firebasestorage#firebasestorage_interface) 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](/docs/reference/js/storage.firebasestorage#firebasestorage_interface) |\n\nRulesTestContext.database()\n\nGet a [Database](/docs/reference/js/database.database#database_class) 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).\n\nSee: [Database](/docs/reference/js/database.database#database_class)\n\n**Signature:** \n\n database(databaseURL?: string): firebase.database.Database;\n\nParameters\n\n| Parameter | Type | Description |\n|-------------|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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 |\n\n**Returns:**\n\nfirebase.database.Database\n\na `Database` instance configured to connect to the emulator. It never connects to production even if a production `databaseURL` is specified\n\nRulesTestContext.firestore()\n\nGet a [Firestore](/docs/reference/js/firestore_.firestore#firestore_class) 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).\n\nSee: [Firestore](/docs/reference/js/firestore_.firestore#firestore_class)\n\n**Signature:** \n\n firestore(settings?: firebase.firestore.Settings): firebase.firestore.Firestore;\n\nParameters\n\n| Parameter | Type | Description |\n|-----------|-----------------------------|------------------------------------------------------------------------------------------------------------------|\n| settings | firebase.firestore.Settings | a settings object to configure the [Firestore](/docs/reference/js/firestore_.firestore#firestore_class) instance |\n\n**Returns:**\n\nfirebase.firestore.Firestore\n\na `Firestore` instance configured to connect to the emulator\n\nRulesTestContext.storage()\n\nGet a [FirebaseStorage](/docs/reference/js/storage.firebasestorage#firebasestorage_interface) 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).\n\nSee: [FirebaseStorage](/docs/reference/js/storage.firebasestorage#firebasestorage_interface)\n\n**Signature:** \n\n storage(bucketUrl?: string): firebase.storage.Storage;\n\nParameters\n\n| Parameter | Type | Description |\n|-----------|--------|-------------|\n| bucketUrl | string | |\n\n**Returns:**\n\nfirebase.storage.Storage\n\na `Storage` instance configured to connect to the emulator"]]