fireorm
fireorm copied to clipboard
setting for runing test with firebase emulator.
I did not get it to work with the latest version of firebase yet but with version 8 you can simply do this:
firebase.initializeApp({
credential: credential.cert(serviceAccount as ServiceAccount),
databaseURL: `https://${serviceAccount.project_id}.firebaseio.com`,
projectId: serviceAccount.project_id,
})
const db = firebase.firestore()
db.useEmulator('localhost', 8080)
fireorm.initialize(db as any, {
validateModels: true,
validatorOptions: {
whitelist: true,
},
})
Had to type db as any because of
Argument of type 'firebase.default.firestore.Firestore' is not assignable to parameter of type 'FirebaseFirestore.Firestore'. Type 'Firestore' is missing the following properties from type 'Firestore': getAll, recursiveDelete, listCollections, bulkWriter, bundlets(2345)
Being able to use emulators for tests and local development is great, so it would definitely be cool if we could get it to work for both v8 (types) and v9 (completely? not sure how to get it to work yet)
The code you send works with version 9.1.3 however I will do what @wovalle