karma-socket-io-server
A Karma plugin that allows you to create a tiny socket.io server to handle some testing cases
$ cnpm install karma-socket-io-server 
SYNC missed versions from official npm registry.

karma-socket-io-server

Launch and configure a Socket.IO server to run your tests against.

About

  • The socket.io.js client library is available at the address specified in the karma.conf file. By default, http://localhost:[port]/socket.io/socket.io.js
  • You can test the allowRequest functionality
  • As many emit and on as needed.
  • You get access to karma's logger.

Installation

npm install -g  karma-socket.io-server

Karma Config file :



module.exports = function (config) {
    config.set({
    
        hostname: 'localhost',
    
        frameworks: [ 'socket-io-server'],

        socketIOServer: {
            // MANDATORY: Which port the server will listen to.
            
            port: 3000,
            
            
            // OPTIONAL: This function allows you to test authorization with handshake. - 
            
            allowRequest: function(handshake, cb) {
                return cb(null, true); // authorize every connections
            },
            
            
            // OPTIONAL: This function takes the socket client which is initialize after the on('connection')
            
            rules: function (socket, log) {
                log.info('Hi I am the karma logger');

                socket.on('SOME_MESSAGE', function( data ) {
                    socket.emit('MESSAGE_RECEIVED');
                });
                
                socket.emit('DID_YOU_RECEIVE', '_this? ');
            }
        }
    });
};


Current Tags

  • 0.0.3                                ...           latest (3 years ago)

1 Versions

  • 0.0.3                                ...           3 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |