From 8b8dc5a8b858edfbb3d80f04c280d1822c1b3d36 Mon Sep 17 00:00:00 2001 From: Nicolas Ferrero Date: Wed, 2 Oct 2013 15:00:00 +0200 Subject: [PATCH] fix: launcher kill method which was throwing an error if no callback was specified bug introduced in https://github.com/karma-runner/karma/commit/8647266fd592fe245aaf2be964319d3026432e33 In server.js when singleRun = true, no callback is passed to when a browser complete to launcher.kill so if a browser is not yet connected but one has already finished the process throw an error. TypeError: undefined is not a function at process._tickCallback (node.js:415:13) --- lib/launcher.js | 4 +++- test/unit/launcher.spec.coffee | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/launcher.js b/lib/launcher.js index ca9ab7f65..c2bf6d771 100644 --- a/lib/launcher.js +++ b/lib/launcher.js @@ -53,7 +53,9 @@ var Launcher = function(emitter, injector) { } } - process.nextTick(callback); + if (callback) { + process.nextTick(callback); + } return false; }; diff --git a/test/unit/launcher.spec.coffee b/test/unit/launcher.spec.coffee index a37438b2d..f2b9ad437 100644 --- a/test/unit/launcher.spec.coffee +++ b/test/unit/launcher.spec.coffee @@ -96,6 +96,13 @@ describe 'launcher', -> expect(l.kill 'weid-id', done).to.equal false expect(browser.kill).not.to.have.been.called + it 'should not resolve callback if none was defined', (done) -> + l.launch ['Fake'] + browser = FakeBrowser._instances.pop() + + expect(l.kill 'weid-id').to.equal false + process.nextTick -> + done() describe 'killAll', -> exitSpy = null