0.2.0 • Published 7 years ago

karma-firebase v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

karma-firebase :fire: CircleCI Codacy Badge

npm version

A simple plugin for integration and e2e testing with Firebase. The plugin is based on firebase-server.

Installation

The easiest way is to install karma-firebase is by doing the following way:

$ npm install karma-firebase --save-dev

Configuration

Once karma-firebase is installed you can make use of it by adding the plugin to your karma configuration file.

karma.conf.js

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.

PropertyDescriptiondefault value
portThe port to launch firebase-server.5000
dataInitial data to load firebase-server with.{}

Usage

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

License

MIT