Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(jasminewd): Use promise.all to combine promises and done
Browse files Browse the repository at this point in the history
- Make the flow promise explicit and use promise.all to wait for both
  promises to be fulfilled before calling the done callback
  • Loading branch information
sgronblo authored and hankduan committed May 16, 2014
1 parent 9e5e6c7 commit e36c32a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jasminewd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,19 @@ function wrapInControlFlow(globalFn, fnName) {
throw Error('Invalid # arguments (' + fn.length + ') within function "' + fnName +'"');
}

flow.execute(function() {
var flowFinished = flow.execute(function() {
fn.call(jasmine.getEnv().currentSpec, function(userError) {
if (userError) {
asyncFnDone.reject(new Error(userError));
} else {
asyncFnDone.fulfill();
}
});
return asyncFnDone.promise;
}, desc_).then(seal(done), function(e) {
}, desc_);

webdriver.promise.all([asyncFnDone, flowFinished]).then(function() {
seal(done)();
}, function(e) {
e.stack = e.stack + '==== async task ====\n' + driverError.stack;
done(e);
});
Expand Down

0 comments on commit e36c32a

Please sign in to comment.