Skip to content

Instantly share code, notes, and snippets.

@kylewelsby
Created February 15, 2014 12:02
Show Gist options
  • Save kylewelsby/9018419 to your computer and use it in GitHub Desktop.
Save kylewelsby/9018419 to your computer and use it in GitHub Desktop.

Testing socket.io onMessage.

phantomjs ./socket_message_test.js

should return the message emitted on exit.

(function(){
'use strict';
page = require('webpage').create();
page.onCallback = function (msg){
console.log(msg);
phantom.exit();
};
page.open('./fixture.html', function () {
page.includeJS('http://localhost:8080/socket.io/socket.io.js',function(){
socket = io.connect('http://localhost:8080');
socket.on('message', function (data) {
phantom.callPhantom(JSON.stringify(data));
});
});
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment