Skip to content

Commit

Permalink
Merge pull request #2049 from DougBlumeyer/feature-emit-error-on-disc…
Browse files Browse the repository at this point in the history
…onnect

feat(browser): Emit a browser error when a disconnect occurs.
  • Loading branch information
dignifiedquire committed Apr 12, 2016
2 parents 2dc4ac8 + 8e15a33 commit 7814de0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var Browser = function (id, fullName, /* capturedBrowsers */ collection, emitter
self.state = DISCONNECTED
self.disconnectsCount++
log.warn('Disconnected (%d times)' + (reason || ''), self.disconnectsCount)
emitter.emit('browser_error', self, 'Disconnected' + reason)
collection.remove(self)
}

Expand Down
4 changes: 4 additions & 0 deletions test/unit/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ describe('Browser', () => {
socket.emit('result', {success: true, suite: [], log: []})
socket.emit('disconnect', 'socket.io reason')

var spyBrowserError = sinon.spy()
emitter.on('browser_error', spyBrowserError)

timer.wind(10)
expect(browser.lastResult.disconnected).to.equal(true)
expect(spy).to.have.been.calledWith(browser)
expect(spyBrowserError).to.have.been.called
})

it('restarting a disconnected browser', () => {
Expand Down

0 comments on commit 7814de0

Please sign in to comment.