Skip to content

Latest commit

 

History

History
executable file
·
38 lines (26 loc) · 1.33 KB

File metadata and controls

executable file
·
38 lines (26 loc) · 1.33 KB

Debugging & Mocking

Debugging

Firebase provides a debugging facility that can be turned on (it's off by default). When turned on it will log all connections and state changes to the firebase client. In order to get this information sent to STDOUT you need specify this when you instantiate an instance:

const db = new DB({ debugging: true });

If you'd prefer to configure a callback which is passed the debugging messages you can do that by:

const callback: DebuggingCallback = (message) => { /** */ };
const db = new DB({ debugging: callback });

Mocking

When you instantiate an instance of abstracted-admin you can choose to connect to a mocked database instead of the real one. You do this by passing in the following configuration:

const db = new DB({ mocking: true });

At this point you can leverage the API provided by the firemock library off of the .mock property. So for instance, if you wanted to setup 10 person records you could state:

const db = new DB({ mocking: true });
db.mock.addSchema('person', personMockGenerator);
db.mock.queueSchema('person', 10).generate();

Now the mock database that abstracted-admin is pointing at has 10 people records. To query those records is no different than a non-mocked database:

const people = await db.getRecords('/people');