From d5df723f97d1b48133416109276feebb0c6fa82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20O=C3=9Fwald?= Date: Wed, 13 Feb 2019 22:52:39 +0100 Subject: [PATCH] fix(browser): allow updating total specs count (#3264) * fix(browser): allow updating total specs count This change allows providing the total specs count after the tests have been started. The count will be updated in case it has been provided already. This can be uselful for some adapters where the total specs count can not be determined before starting the first test. fix onInfo test case, add new test for total update --- lib/browser.js | 4 ++++ test/unit/browser.spec.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/browser.js b/lib/browser.js index f4389c172..699fe42ee 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -60,6 +60,10 @@ class Browser { if (helper.isDefined(info.log)) { this.emitter.emit('browser_log', this, info.log, info.type) + } else if (helper.isDefined(info.total)) { + if (this.state === EXECUTING) { + this.lastResult.total = info.total + } } else if (!helper.isDefined(info.dump)) { this.emitter.emit('browser_info', this, info) } diff --git a/test/unit/browser.spec.js b/test/unit/browser.spec.js index 33eca8013..3bd242ee5 100644 --- a/test/unit/browser.spec.js +++ b/test/unit/browser.spec.js @@ -123,12 +123,19 @@ describe('Browser', () => { expect(spy).to.have.been.calledWith(browser, infoData) }) - it('should ignore if browser not executing', () => { + it('should update total specs count during execution', () => { + browser.state = Browser.STATE_EXECUTING + browser.onInfo({total: 20}) + + expect(browser.lastResult.total).to.equal(20) + }) + + it('should ignore update total if not executing', () => { const spy = sinon.spy() - emitter.on('browser_dump', spy) + emitter.on('browser_log', spy) + emitter.on('browser_info', spy) browser.state = Browser.STATE_CONNECTED - browser.onInfo({dump: 'something'}) browser.onInfo({total: 20}) expect(browser.lastResult.total).to.equal(0)