Skip to content

Commit

Permalink
fix: send specNames only when using web/flash socket
Browse files Browse the repository at this point in the history
This structure can be pretty big and it blows up socket.io when polling.
  • Loading branch information
vojtajina committed Aug 20, 2013
1 parent 35b063d commit 302fc66
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ var indexOf = function(collection, item) {
};


// TODO(vojta): Karma might provide this
var getCurrentTransport = function() {
var location = window.parent.location;
return window.parent.io.sockets[location.protocol + '//' + location.host].transport.name;
};


/**
* Very simple reporter for jasmine
*/
var KarmaReporter = function(tc) {

this.reportRunnerStarting = function(runner) {
var topLevelSuites = runner.topLevelSuites();
var getAllSpecNames = function(topLevelSuites) {
var specNames = {};

var processSuite = function(suite, pointer) {
Expand All @@ -64,6 +70,19 @@ var KarmaReporter = function(tc) {
processSuite(suite, pointer);
}

return specNames;
};

this.reportRunnerStarting = function(runner) {
var transport = getCurrentTransport();
var specNames = null;

// This structure can be pretty huge and it blows up socke.io connection, when polling.
// https://github.com/LearnBoost/socket.io-client/issues/569
if (transport === 'websocket' || transport === 'flashsocket') {
specNames = getAllSpecNames(runner.topLevelSuites());
}

tc.info({total: runner.specs().length, specs: specNames});
};

Expand Down

0 comments on commit 302fc66

Please sign in to comment.