diff --git a/spec/atom-reporter.coffee b/spec/atom-reporter.coffee index dfb9da5b6..c02035cc8 100644 --- a/spec/atom-reporter.coffee +++ b/spec/atom-reporter.coffee @@ -1,5 +1,6 @@ $ = require 'jquery' {View, $$} = require 'space-pen' +_ = require 'underscore' module.exports = class AtomReporter extends View @@ -68,6 +69,8 @@ class AtomReporter extends View clearTimeout @timeoutId if @timeoutId? @specPopup.show() + spec = _.find(window.timedSpecs, (spec) -> description is spec.name) + description = "#{description} #{spec.time}ms" if spec @specPopup.text description {left, top} = element.offset() left += 20 diff --git a/spec/time-reporter.coffee b/spec/time-reporter.coffee index 6546a68bd..7004072ef 100644 --- a/spec/time-reporter.coffee +++ b/spec/time-reporter.coffee @@ -3,21 +3,23 @@ _ = require 'underscore' module.exports = class TimeReporter extends jasmine.Reporter - timedSpecs: [] - timedSuites: {} - constructor: -> + window.timedSpecs = [] + window.timedSuites = {} + window.logLongestSpec = -> window.logLongestSpecs(1) + window.logLongestSpecs = (number=10) => console.log "#{number} longest running specs:" - for spec in _.sortBy(@timedSpecs, (spec) -> -spec.time)[0...number] + for spec in _.sortBy(window.timedSpecs, (spec) -> -spec.time)[0...number] console.log "#{spec.time}ms" console.log spec.description window.logLongestSuite = -> window.logLongestSuites(1) + window.logLongestSuites = (number=10) => console.log "#{number} longest running suites:" - suites = _.map(@timedSuites, (key, value) -> [value, key]) + suites = _.map(window.timedSuites, (key, value) -> [value, key]) for suite in _.sortBy(suites, (suite) => -suite[1])[0...number] console.log suite[0], suite[1] @@ -34,16 +36,17 @@ class TimeReporter extends jasmine.Reporter "#{memo}#{_.multiplyString(' ', index)}#{description}\n" @description = _.reduce(stack, reducer, "") - reportSpecResults: -> + reportSpecResults: (spec) -> return unless @time? and @description? duration = new Date().getTime() - @time - @timedSpecs.push + window.timedSpecs.push description: @description time: duration - if @timedSuites[@suite] - @timedSuites[@suite] += duration + name: spec.getFullName() + if timedSuites[@suite] + window.timedSuites[@suite] += duration else - @timedSuites[@suite] = duration + window.timedSuites[@suite] = duration @time = null @description = null