fireorm icon indicating copy to clipboard operation
fireorm copied to clipboard

setting for runing test with firebase emulator.

Open abejarano opened this issue 3 years ago • 2 comments

abejarano avatar Oct 20 '21 17:10 abejarano

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)

donnyroufs avatar Oct 24 '21 18:10 donnyroufs

The code you send works with version 9.1.3 however I will do what @wovalle

abejarano avatar Oct 25 '21 10:10 abejarano