[6a3a178] | 1 | const BaseReporter = require('./base')
|
---|
| 2 |
|
---|
| 3 | function ProgressReporter (formatError, reportSlow, useColors, browserConsoleLogOptions) {
|
---|
| 4 | BaseReporter.call(this, formatError, reportSlow, useColors, browserConsoleLogOptions)
|
---|
| 5 |
|
---|
| 6 | this.EXCLUSIVELY_USE_COLORS = false
|
---|
| 7 | this._browsers = []
|
---|
| 8 |
|
---|
| 9 | this.writeCommonMsg = function (msg) {
|
---|
| 10 | this.write(this._remove() + msg + this._render())
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | this.specSuccess = function () {
|
---|
| 14 | this.write(this._refresh())
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | this.onBrowserComplete = function () {
|
---|
| 18 | this.write(this._refresh())
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | this.onRunStart = function () {
|
---|
| 22 | this._browsers = []
|
---|
| 23 | this._isRendered = false
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | this.onBrowserStart = function (browser) {
|
---|
| 27 | this._browsers.push(browser)
|
---|
| 28 |
|
---|
| 29 | if (this._isRendered) {
|
---|
| 30 | this.write('\n')
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | this.write(this._refresh())
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | this._remove = function () {
|
---|
| 37 | if (!this._isRendered) {
|
---|
| 38 | return ''
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | let cmd = ''
|
---|
| 42 | this._browsers.forEach(function () {
|
---|
| 43 | cmd += '\x1B[1A' + '\x1B[2K'
|
---|
| 44 | })
|
---|
| 45 |
|
---|
| 46 | this._isRendered = false
|
---|
| 47 |
|
---|
| 48 | return cmd
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | this._render = function () {
|
---|
| 52 | this._isRendered = true
|
---|
| 53 |
|
---|
| 54 | return this._browsers.map(this.renderBrowser).join('\n') + '\n'
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | this._refresh = function () {
|
---|
| 58 | return this._remove() + this._render()
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | // PUBLISH
|
---|
| 63 | module.exports = ProgressReporter
|
---|