I'm making an API with NodeJS and FireBase DataBase, so I want to check if the connection with the database is well established, mainly because I want to create a unit test that will verify if everything is alright with the connection. Below is my code, I have a class where I have everything related to the DB, I would like to have either a property or a method that gives me true if its connected or false if it's not. please, help.
var con = false;
var connectedRef = this.db.ref(".info/connected");
connectedRef.on("value", function (snap) {
if (snap.val() === true) {
con = true;
} else {
con = false;
}
})
this.con = con;