Skip to content

Commit

Permalink
fix(launcher): Only markCaptured browsers that are launched. (#3047)
Browse files Browse the repository at this point in the history
This is a regression in 2.0.3: if karma server is started and a users browser attached, the launch throws
  • Loading branch information
johnjbarton authored Jun 16, 2018
1 parent 333e7d4 commit f8f3ebc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ function Launcher (server, emitter, injector) {

this.markCaptured = (id) => {
const browser = getBrowserById(id)
browser.markCaptured()
log.debug(`${browser.name} (id ${browser.id}) captured in ${(Date.now() - lastStartTime) / 1000} secs`)
if (browser) {
browser.markCaptured()
log.debug(`${browser.name} (id ${browser.id}) captured in ${(Date.now() - lastStartTime) / 1000} secs`)
}
}

emitter.on('exit', this.killAll)
Expand Down
6 changes: 6 additions & 0 deletions test/unit/launcher.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ describe('launcher', () => {
})
})

describe('markCaptured', () => {
it('should not fail if an un-launched browser attaches', () => {
expect(() => l.markCaptured('not-a-thing')).to.not.throw()
})
})

describe('onExit', () => {
it('should kill all browsers', (done) => {
l.launch(['Fake', 'Fake'], 1)
Expand Down

0 comments on commit f8f3ebc

Please sign in to comment.