soumak77 / firebase-mock

Firebase mock library for writing unit tests
https://soumak77.github.io/firebase-mock
350 stars 96 forks source link

How to write a unit-test for read data from firebase realtime database #118

Open wiadev opened 5 years ago

wiadev commented 5 years ago

Hi. I've checked your sample code but can't figure out how to use it.

Here is my source code.

addListener () {
  this.db.ref('age').once('value', (snap) => { ... }
);

FYI, this.db = firebase.database() from require('firebase');

The source code is working fine by reading data from Realtime Database.

I need to write a unit test for this part.

I tried to use firebase-mock but no idea how to do it.

Can you please help me?

Thanks. @soumak77

stefdelec commented 4 years ago

I do agree with you! Tutorial are not very clear. They use method 'overide', like MockFirebase.override(); but this method does not exist.