A simple plugin for integration
and e2e
testing with Firebase. The plugin is based on firebase-server
.
The easiest way is to install karma-firebase
is by doing the following way:
$ npm install karma-firebase --save-dev
Once karma-firebase
is installed you can make use of it by adding the plugin to your karma configuration file.
module.exports = function(config) {
config.set({
// add karma-firebase to the plugins array
plugins: [
'karma-firebase'
],
// execute the plugin before karma's middleware
beforeMiddleware: ['firebase'],
// add your config
firebase: {
// set the port of the websocket server
port: 4500,
// add initial data to the database
data: {
name: 'John Doe',
age: '24'
},
},
})
}
You are able to configure the plugin within the firebase
property.
Property | Description | default value |
---|---|---|
port | The port to launch firebase-server . |
5000 |
data | Initial data to load firebase-server with. |
{} |
Once the configuration is setup you can make use of the firebase-server
within your tests.
Simply initialize the firebase app the following way:
// initialize firebase with the port you've specified
firebase.initializeApp({ databaseURL: 'ws://127.0.1:4500' });
// simply create a database reference
ref = firebase.app().database().ref();
// ... and happy testing
MIT