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

Commit

Permalink
fix(clientsidescript): avoid returning the value of test callback in …
Browse files Browse the repository at this point in the history
…waitForAngular (#4667)

The return value could be interpreted as an error by mistake in some situation
Also fix a wrong if-condition in error reporting
  • Loading branch information
qiyigg authored Jan 24, 2018
1 parent 335680f commit 964baba
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/clientsidescripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ functions.waitForAngular = function(rootSelector, callback) {
} else if (hooks.$injector) {
hooks.$injector.get('$browser')
.notifyWhenNoOutstandingRequests(callback);
} else if (!!rootSelector) {
} else if (!rootSelector) {
throw new Error(
'Could not automatically find injector on page: "' +
window.location.toString() + '". Consider using config.rootEl');
Expand All @@ -178,7 +178,8 @@ functions.waitForAngular = function(rootSelector, callback) {
}
catch(e){}
if (testability) {
return testability.whenStable(function() { testCallback(); });
testability.whenStable(testCallback);
return;
}
}

Expand All @@ -191,7 +192,8 @@ functions.waitForAngular = function(rootSelector, callback) {
// No angular2 testability, this happens when
// going to a hybrid page and going back to a pure angular1 page
if (count === 0) {
return testCallback();
testCallback();
return;
}

var decrement = function() {
Expand Down Expand Up @@ -696,7 +698,7 @@ functions.findByCssContainingText = function(cssSelector, searchText, using) {
var elementMatches = searchText instanceof RegExp ?
searchText.test(elementText) :
elementText.indexOf(searchText) > -1;

if (elementMatches) {
matches.push(element);
}
Expand Down

0 comments on commit 964baba

Please sign in to comment.