Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
matz3 authored and johnjbarton committed Feb 13, 2019
1 parent c277a6b commit d5df723
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/browser.js
Expand Up @@ -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)
}
Expand Down
13 changes: 10 additions & 3 deletions test/unit/browser.spec.js
Expand Up @@ -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)
Expand Down

0 comments on commit d5df723

Please sign in to comment.