Socket
Book a DemoInstallSign in
Socket

karma-websocket-server

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-websocket-server

Karma plugin to create a websocket server for unit tests

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

karma-websocket-server

Makes it easy to globally start a websocket-node server for karma unit tests.

Installation

npm install karma-websocket-server --save-dev

Usage

// karma.conf.js
module.exports = function(config) {
  // ... snip
  frameworks: [ 'websocket-server' ],
  websocketServer: {
    port: 8889,
    beforeStart: (server) => {
      server.on('request', (req) => {
        console.log(new Date() + ' new websocket request...');
      });
    },
    afterStart: (server) => {
      console.log('Server now listening!');
    }
  }
});

The configuration object

After the framework is added to the karma configuration, you can control its behaviour with the websocketServer configuration object. The object holds three seperate items:

port (Number):

The port the server will run on. Defaults to 8889 if not provided.

beforeStart (Function):

This callback is invoked directly before the http server starts to listen. It takes the created websocket server instance as parameter. Use this callback to add listeners (like request) to the configuration.

afterStart (Function):

This callback is invoked after the http server has started. It takes the created websocket server instance as parameter.

Special thanks

Special thanks go to Tadas Subonis for creating karma-express-http-server where I borrowed some of the code.

Licence

karma-websocket-server is available under MIT-License and can therefore be used in any project free of charge.

Keywords

karma-plugin

FAQs

Package last updated on 06 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.