firebase-mock icon indicating copy to clipboard operation
firebase-mock copied to clipboard

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

Open wiadev opened this issue 7 years ago • 1 comments

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

wiadev avatar Nov 07 '18 10:11 wiadev

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

stefdelec avatar May 09 '20 13:05 stefdelec