code: function(callback) {
  
        if (window.angular) {
          var hooks = getNg1Hooks(rootSelector);
          if (!hooks){
            callback();  // not an angular1 app
          }
          else{
            if (hooks.$$testability) {
              hooks.$$testability.whenStable(callback);
            } else if (hooks.$injector) {
              hooks.$injector.get('$browser')
                  .notifyWhenNoOutstandingRequests(callback);
            } else if (!rootSelector) {
              throw new Error(
                  'Could not automatically find injector on page: "' +
                  window.location.toString() + '".  Consider using config.rootEl');
            } else {
              throw new Error(
                  'root element (' + rootSelector + ') has no injector.' +
                  ' this may mean it is not inside ng-app.');
            }
          }
        }
        else {callback();}  // not an angular1 app
      }
docs: Wait for angular1 testability first and run waitForAngular2 as a callback