karma-firebase

0.2.0 • Public • Published

karma-firebase 🔥 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.

Property Description default value
port The port to launch firebase-server. 5000
data Initial 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

Package Sidebar

Install

npm i karma-firebase

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • orlandster