|
|
@ -8,8 +8,8 @@ var flatten = require('arr-flatten'); |
|
|
|
var figures = require('figures'); |
|
|
|
var formatter = require('./enhance-assert').formatter(); |
|
|
|
|
|
|
|
function TestData(opts) { |
|
|
|
if (!(this instanceof TestData)) { |
|
|
|
function RunStatus(opts) { |
|
|
|
if (!(this instanceof RunStatus)) { |
|
|
|
throw new TypeError('Class constructor TestData cannot be invoked without \'new\''); |
|
|
|
} |
|
|
|
EventEmitter.call(this); |
|
|
@ -31,15 +31,15 @@ function TestData(opts) { |
|
|
|
this.stats = []; |
|
|
|
this.tests = []; |
|
|
|
|
|
|
|
Object.keys(TestData.prototype).forEach(function (key) { |
|
|
|
Object.keys(RunStatus.prototype).forEach(function (key) { |
|
|
|
this[key] = this[key].bind(this); |
|
|
|
}, this); |
|
|
|
} |
|
|
|
|
|
|
|
util.inherits(TestData, EventEmitter); |
|
|
|
module.exports = TestData; |
|
|
|
util.inherits(RunStatus, EventEmitter); |
|
|
|
module.exports = RunStatus; |
|
|
|
|
|
|
|
TestData.prototype.observeFork = function (emitter) { |
|
|
|
RunStatus.prototype.observeFork = function (emitter) { |
|
|
|
emitter |
|
|
|
.on('teardown', this.handleTeardown) |
|
|
|
.on('stats', this.handleStats) |
|
|
@ -61,7 +61,7 @@ function normalizeError(err) { |
|
|
|
return err; |
|
|
|
} |
|
|
|
|
|
|
|
TestData.prototype.handleRejections = function (data) { |
|
|
|
RunStatus.prototype.handleRejections = function (data) { |
|
|
|
this.rejectionCount += data.rejections.length; |
|
|
|
|
|
|
|
data.rejections.forEach(function (err) { |
|
|
@ -73,7 +73,7 @@ TestData.prototype.handleRejections = function (data) { |
|
|
|
}, this); |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.handleExceptions = function (data) { |
|
|
|
RunStatus.prototype.handleExceptions = function (data) { |
|
|
|
this.exceptionCount++; |
|
|
|
var err = normalizeError(data.exception); |
|
|
|
err.type = 'exception'; |
|
|
@ -82,11 +82,11 @@ TestData.prototype.handleExceptions = function (data) { |
|
|
|
this.errors.push(err); |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.handleTeardown = function (data) { |
|
|
|
RunStatus.prototype.handleTeardown = function (data) { |
|
|
|
this.emit('dependencies', data.file, data.dependencies, this); |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.handleStats = function (stats) { |
|
|
|
RunStatus.prototype.handleStats = function (stats) { |
|
|
|
this.emit('stats', stats, this); |
|
|
|
|
|
|
|
if (this.hasExclusive && !stats.hasExclusive) { |
|
|
@ -101,7 +101,7 @@ TestData.prototype.handleStats = function (stats) { |
|
|
|
this.testCount += stats.testCount; |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.handleTest = function (test) { |
|
|
|
RunStatus.prototype.handleTest = function (test) { |
|
|
|
test.title = this.prefixTitle(test.file) + test.title; |
|
|
|
|
|
|
|
if (test.error) { |
|
|
@ -125,7 +125,7 @@ TestData.prototype.handleTest = function (test) { |
|
|
|
this.emit('test', test, this); |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.prefixTitle = function (file) { |
|
|
|
RunStatus.prototype.prefixTitle = function (file) { |
|
|
|
if (!this.prefixTitles) { |
|
|
|
return ''; |
|
|
|
} |
|
|
@ -148,11 +148,11 @@ TestData.prototype.prefixTitle = function (file) { |
|
|
|
return prefix; |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.handleOutput = function (channel, data) { |
|
|
|
RunStatus.prototype.handleOutput = function (channel, data) { |
|
|
|
this.emit(channel, data, this); |
|
|
|
}; |
|
|
|
|
|
|
|
TestData.prototype.processResults = function (results) { |
|
|
|
RunStatus.prototype.processResults = function (results) { |
|
|
|
// assemble stats from all tests
|
|
|
|
this.stats = results.map(function (result) { |
|
|
|
return result.stats; |
|
|
|