The testing app instance
Sets the given app to be used for Firestore operations. Must be used after
calling injectTestingAdaptor
.
import * as testing from '@firebase/testing'
import { injectTestingAdaptor, setApp } from 'typesaurus/testing'
// Initialize as not authenticated:
injectTestingAdaptor(
testing.initializeTestApp({
projectId: 'project-id',
auth: null
})
)
// Authenticate user with user-id as the id:
setApp(
testing.initializeTestApp({
projectId: 'project-id',
auth: { user: 'user-id' }
})
)
The testing app instance
Generated using TypeDoc
Injects @firebase/testing adaptod instead of firebase-admin and set the given app to be used for Firestore operations.
import * as testing from '@firebase/testing' import { injectTestingAdaptor } from 'typesaurus/testing' // To initialize and inject an admin app (with exclusive access to the DB): injectTestingAdaptor(testing.initializeAdminApp({ projectId: 'project-id' })) // To initialize and inject a client app (with given authentication details): injectTestingAdaptor( testing.initializeTestApp({ projectId: 'project-id', auth: { uid: 'user-id' } }) ) // Load security rules: await testing.loadFirestoreRules({ projectId: 'project-id', rules: '' // Security rules string })