From ac4d1fad579fb7e4bba57081b5841fe250f39b5e Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Wed, 13 Feb 2019 12:09:05 +0100 Subject: [PATCH 1/3] 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. --- lib/browser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/browser.js b/lib/browser.js index f4389c172..0d226e802 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -60,6 +60,8 @@ class Browser { if (helper.isDefined(info.log)) { this.emitter.emit('browser_log', this, info.log, info.type) + } else if (helper.isDefined(info.total)) { + this.lastResult.total = info.total } else if (!helper.isDefined(info.dump)) { this.emitter.emit('browser_info', this, info) } From 217a7dee7ad4c5e24ff271e948603aba1df756ae Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Wed, 13 Feb 2019 18:27:40 +0100 Subject: [PATCH 2/3] fix(browser): only update total count when executing --- lib/browser.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/browser.js b/lib/browser.js index 0d226e802..699fe42ee 100644 --- a/lib/browser.js +++ b/lib/browser.js @@ -61,7 +61,9 @@ class Browser { if (helper.isDefined(info.log)) { this.emitter.emit('browser_log', this, info.log, info.type) } else if (helper.isDefined(info.total)) { - this.lastResult.total = info.total + if (this.state === EXECUTING) { + this.lastResult.total = info.total + } } else if (!helper.isDefined(info.dump)) { this.emitter.emit('browser_info', this, info) } From 18eec879dab345cacac0e233d2c2908874448f4a Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Wed, 13 Feb 2019 18:30:19 +0100 Subject: [PATCH 3/3] test(browser): fix onInfo test case, add new test for total update --- test/unit/browser.spec.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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)