dots.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var BaseReporter = require('./base')
  2. var DotsReporter = function (formatError, reportSlow, useColors, browserConsoleLogOptions) {
  3. BaseReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)
  4. var DOTS_WRAP = 80
  5. this.EXCLUSIVELY_USE_COLORS = false
  6. this.onRunStart = function () {
  7. this._browsers = []
  8. this._dotsCount = 0
  9. }
  10. this.onBrowserStart = function (browser) {
  11. this._browsers.push(browser)
  12. }
  13. this.writeCommonMsg = function (msg) {
  14. if (this._dotsCount) {
  15. this._dotsCount = 0
  16. msg = '\n' + msg
  17. }
  18. this.write(msg)
  19. }
  20. this.specSuccess = function () {
  21. this._dotsCount = (this._dotsCount + 1) % DOTS_WRAP
  22. this.write(this._dotsCount ? '.' : '.\n')
  23. }
  24. this.onBrowserComplete = function (browser) {
  25. this.writeCommonMsg(this.renderBrowser(browser) + '\n')
  26. }
  27. this.onRunComplete = function (browsers, results) {
  28. if (browsers.length > 1 && !results.disconnected && !results.error) {
  29. if (!results.failed) {
  30. this.write(this.TOTAL_SUCCESS, results.success)
  31. } else {
  32. this.write(this.TOTAL_FAILED, results.failed, results.success)
  33. }
  34. }
  35. }
  36. }
  37. // PUBLISH
  38. module.exports = DotsReporter