From 1afbc7e458d81d9a27ac6116ffb50b1622446c9c Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Fri, 18 Mar 2016 00:10:43 -0400 Subject: [PATCH] bug(test): resolve test race condition Starting build and test at the same time creates a race condition Run a build first to remove that scenario Fixes #293 --- addon/ng2/commands/test.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addon/ng2/commands/test.js b/addon/ng2/commands/test.js index 9560e4897d9f..80d9ebe1c328 100644 --- a/addon/ng2/commands/test.js +++ b/addon/ng2/commands/test.js @@ -51,7 +51,11 @@ module.exports = TestCommand.extend({ if (commandOptions.watch){ return win.checkWindowsElevation(this.ui) - .then(function() { + .then(_ => { + // perform initial build to avoid race condition + return buildTask.run(buildOptions); + }, _ => { /* handle build error to allow watch mode to start */}) + .then(_ => { return Promise.all([ buildWatchTask.run(buildOptions), testTask.run(commandOptions) @@ -61,10 +65,10 @@ module.exports = TestCommand.extend({ // if not watching ensure karma is doing a single run commandOptions.singleRun = true; return win.checkWindowsElevation(this.ui) - .then(function() { + .then(_ => { return buildTask.run(buildOptions); }) - .then(function(){ + .then(_ => { return testTask.run(commandOptions); }); }