Skip to content

Commit 8aceee2

Browse files
Broccofilipesilva
authored andcommitted
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 angular#293 Closes angular#311
1 parent f2f5ff9 commit 8aceee2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

addon/ng2/commands/test.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ module.exports = TestCommand.extend({
5151

5252
if (commandOptions.watch){
5353
return win.checkWindowsElevation(this.ui)
54-
.then(function() {
54+
.then(_ => {
55+
// perform initial build to avoid race condition
56+
return buildTask.run(buildOptions);
57+
}, _ => { /* handle build error to allow watch mode to start */})
58+
.then(_ => {
5559
return Promise.all([
5660
buildWatchTask.run(buildOptions),
5761
testTask.run(commandOptions)
@@ -61,10 +65,10 @@ module.exports = TestCommand.extend({
6165
// if not watching ensure karma is doing a single run
6266
commandOptions.singleRun = true;
6367
return win.checkWindowsElevation(this.ui)
64-
.then(function() {
68+
.then(_ => {
6569
return buildTask.run(buildOptions);
6670
})
67-
.then(function(){
71+
.then(_ => {
6872
return testTask.run(commandOptions);
6973
});
7074
}

0 commit comments

Comments
 (0)