setting for runing test with firebase emulator.#281
setting for runing test with firebase emulator.#281abejarano wants to merge 1 commit intowovalle:masterfrom
Conversation
wovalle
left a comment
There was a problem hiding this comment.
Hi Abejarano. Thanks for the pull request!
I understand the value of having the ability to test with the emulator but I think that executing integration tests with a real database is the best case scenario. I would love the idea to have both scenarios though.
- How do you fire of the emulator in the first place? Can you add the script in the package.json?
- Can you update your pull request to accept an env var such as
RUN_IN_EMULATORthat would conditionally replace the firestore initialization to support the 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
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 |
No description provided.