From 1acbd0047195022d38257c5deb4d37df42e2b7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Thu, 23 Jan 2014 13:53:54 +0100 Subject: [PATCH] Fixed timing-dependent unit-tests failures DebuggerAgent.resume unit-test should pass `done` as the callback function, otherwise other tests may run before this one is finished. Fixed launcher so that it runs the test callback only once, instead of everytime a `break` event is emitted. --- test/DebuggerAgent.js | 14 ++++++++++---- test/helpers/launcher.js | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/test/DebuggerAgent.js b/test/DebuggerAgent.js index 0cf681e..ecb4425 100644 --- a/test/DebuggerAgent.js +++ b/test/DebuggerAgent.js @@ -227,10 +227,8 @@ describe('DebuggerAgent', function() { before(setupDebugScenario); it('does not throw an error', function(done) { - expect(function () { agent.resume(); }) + expect(function () { agent.resume({}, done); }) .to.not.throw(); - - done(); }); var debuggerClient, agent; @@ -238,7 +236,15 @@ describe('DebuggerAgent', function() { function setupDebugScenario(done) { launcher.runOnBreakInFunction(function(client) { debuggerClient = client; - agent = new DebuggerAgent({}, null, debuggerClient, null, null); + var frontEndClientStub = { + sendEvent: function() {} + }; + agent = new DebuggerAgent( + {}, + frontEndClientStub, + debuggerClient, + null, // BreakEventHandler + null); // ScripManager done(); }); } diff --git a/test/helpers/launcher.js b/test/helpers/launcher.js index ca97c49..b0c12a6 100644 --- a/test/helpers/launcher.js +++ b/test/helpers/launcher.js @@ -44,7 +44,7 @@ function startDebugger(scriptPath, done) { function runOnBreakInFunction(test) { stopAllDebuggers(); startDebugger('BreakInFunction.js', function(childProcess, debuggerClient) { - debuggerClient.on('break', function() { + debuggerClient.once('break', function() { test(debuggerClient); }); childProcess.stdin.write('go!\n'); @@ -55,7 +55,7 @@ function runOnBreakInFunction(test) { function runInspectObject(test) { stopAllDebuggers(); startDebugger('InspectObject.js', function(childProcess, debuggerClient) { - debuggerClient.on('break', function() { + debuggerClient.once('break', function() { debuggerClient.fetchObjectId( debuggerClient, 'inspectedObject',