diff --git a/jasmine/jasmine.headless-reporter.coffee b/jasmine/jasmine.headless-reporter.coffee index 0b31d03..9d965ab 100644 --- a/jasmine/jasmine.headless-reporter.coffee +++ b/jasmine/jasmine.headless-reporter.coffee @@ -5,6 +5,8 @@ class HeadlessReporterResult constructor: (name) -> @name = name @results = [] + addResult: (message) -> + @results.push(message) print: -> JHW.printName(@name) for result in @results @@ -15,17 +17,16 @@ class jasmine.HeadlessReporter constructor: -> @results = [] @failedCount = 0 - @totalDuration = 0.0 @length = 0 reportRunnerResults: (runner) -> for result in @results do (result) => result.print() - JHW.finishSuite(@totalDuration / 1000.0, @length, @failedCount) + JHW.finishSuite((new Date() - @startTime) / 1000.0, @length, @failedCount) reportRunnerStarting: (runner) -> + @startTime = new Date() reportSpecResults: (spec) -> - @totalDuration += (new Date() - spec.startTime) if spec.results().passed() JHW.specPassed() else @@ -35,9 +36,8 @@ class jasmine.HeadlessReporter do (result) => if result.type == 'expect' and !result.passed_ @failedCount += 1 - failureResult.results.push(result.message) + failureResult.addResult(result.message) @results.push(failureResult) reportSpecStarting: (spec) -> - spec.startTime = new Date() reportSuiteResults: (suite) -> @length += suite.specs().length diff --git a/jasmine/jasmine.headless-reporter.js b/jasmine/jasmine.headless-reporter.js index f803f6d..5170bbd 100644 --- a/jasmine/jasmine.headless-reporter.js +++ b/jasmine/jasmine.headless-reporter.js @@ -9,6 +9,9 @@ this.name = name; this.results = []; } + HeadlessReporterResult.prototype.addResult = function(message) { + return this.results.push(message); + }; HeadlessReporterResult.prototype.print = function() { var result, _i, _len, _ref, _results; JHW.printName(this.name); @@ -28,7 +31,6 @@ function HeadlessReporter() { this.results = []; this.failedCount = 0; - this.totalDuration = 0.0; this.length = 0; } HeadlessReporter.prototype.reportRunnerResults = function(runner) { @@ -41,12 +43,13 @@ result = _ref[_i]; _fn(result); } - return JHW.finishSuite(this.totalDuration / 1000.0, this.length, this.failedCount); + return JHW.finishSuite((new Date() - this.startTime) / 1000.0, this.length, this.failedCount); + }; + HeadlessReporter.prototype.reportRunnerStarting = function(runner) { + return this.startTime = new Date(); }; - HeadlessReporter.prototype.reportRunnerStarting = function(runner) {}; HeadlessReporter.prototype.reportSpecResults = function(spec) { var failureResult, result, _fn, _i, _len, _ref; - this.totalDuration += new Date() - spec.startTime; if (spec.results().passed()) { return JHW.specPassed(); } else { @@ -56,7 +59,7 @@ _fn = __bind(function(result) { if (result.type === 'expect' && !result.passed_) { this.failedCount += 1; - return failureResult.results.push(result.message); + return failureResult.addResult(result.message); } }, this); for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -66,9 +69,7 @@ return this.results.push(failureResult); } }; - HeadlessReporter.prototype.reportSpecStarting = function(spec) { - return spec.startTime = new Date(); - }; + HeadlessReporter.prototype.reportSpecStarting = function(spec) {}; HeadlessReporter.prototype.reportSuiteResults = function(suite) { return this.length += suite.specs().length; };