Skip to content

Commit d5df723

Browse files
matz3johnjbarton
authored andcommitted
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
1 parent c277a6b commit d5df723

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/browser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class Browser {
6060

6161
if (helper.isDefined(info.log)) {
6262
this.emitter.emit('browser_log', this, info.log, info.type)
63+
} else if (helper.isDefined(info.total)) {
64+
if (this.state === EXECUTING) {
65+
this.lastResult.total = info.total
66+
}
6367
} else if (!helper.isDefined(info.dump)) {
6468
this.emitter.emit('browser_info', this, info)
6569
}

test/unit/browser.spec.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,19 @@ describe('Browser', () => {
123123
expect(spy).to.have.been.calledWith(browser, infoData)
124124
})
125125

126-
it('should ignore if browser not executing', () => {
126+
it('should update total specs count during execution', () => {
127+
browser.state = Browser.STATE_EXECUTING
128+
browser.onInfo({total: 20})
129+
130+
expect(browser.lastResult.total).to.equal(20)
131+
})
132+
133+
it('should ignore update total if not executing', () => {
127134
const spy = sinon.spy()
128-
emitter.on('browser_dump', spy)
135+
emitter.on('browser_log', spy)
136+
emitter.on('browser_info', spy)
129137

130138
browser.state = Browser.STATE_CONNECTED
131-
browser.onInfo({dump: 'something'})
132139
browser.onInfo({total: 20})
133140

134141
expect(browser.lastResult.total).to.equal(0)

0 commit comments

Comments
 (0)