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

Commit

Permalink
feat(hybrid): set ng12hybrid flag in the config (#3452)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjelin authored and cnishina committed Oct 26, 2016
1 parent 3e4bc27 commit 7083426
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
6 changes: 4 additions & 2 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,10 @@ export class ProtractorBrowser extends Webdriver {
* Create a new instance of Browser by wrapping a webdriver instance.
*
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
* @param {boolean=} opt_untrackOutstandingTimeouts Whether Browser should
* @param {string=} baseUrl A URL to prepend to relative gets.
* @param {string=} rootElement The css selector for the element which is the
* root of the Angular app.
* @param {boolean=} untrackOutstandingTimeouts Whether Browser should
* stop tracking outstanding $timeouts.
* @returns {Browser} a new Browser instance
*/
Expand Down
9 changes: 9 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,15 @@ export interface Config {
*/
disableEnvironmentOverrides?: boolean;

/**
* Tells Protractor to interpret any angular apps it comes across as hybrid
* angular1/angular2 apps (i.e. apps using ngUpgrade)
* Defaults to `false`
*
* @type {boolean}
*/
ng12Hybrid?: boolean;

seleniumArgs?: Array<any>;
configDir?: string;
troubleshoot?: boolean;
Expand Down
1 change: 1 addition & 0 deletions lib/configParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class ConfigParser {
noGlobals: false,
plugins: [],
skipSourceMapSupport: false,
ng12Hybrid: false
};
}

Expand Down
3 changes: 3 additions & 0 deletions lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ export class Runner extends EventEmitter {
if (config.useAllAngular2AppRoots) {
browser_.useAllAngular2AppRoots();
}
if (config.ng12Hybrid) {
browser_.ng12Hybrid = config.ng12Hybrid;
}

browser_.ready =
driver.manage().timeouts().setScriptTimeout(config.allScriptsTimeout);
Expand Down
16 changes: 8 additions & 8 deletions spec/hybrid/async_spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
describe('async angular1/2 hybrid using ngUpgrade application', function() {
beforeEach(function() {
browser.ng12Hybrid = true;

browser.get('/hybrid');
});

afterEach(function() {
browser.ng12Hybrid = false;
});

it('should propertly load the page', function() {
expect($('h1').getText()).toEqual('My App');
it('should set browser flag via config', function() {
expect(browser.ng12Hybrid).toBe(true);
});

it('should be able to click buttons and wait for $timeout', function() {
Expand All @@ -29,4 +23,10 @@ describe('async angular1/2 hybrid using ngUpgrade application', function() {
ng1Btn.click();
expect(ng1Btn.getText()).toEqual('Click Count: 1');
});

it('should use the flag on the browser object', function() {
browser.ng12Hybrid = false;
browser.get('/ng2'); // will time out if Protractor expects hybrid
browser.ng12Hybrid = true;
});
});
4 changes: 3 additions & 1 deletion spec/hybridConf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ exports.config = {

baseUrl: env.baseUrl,

rootElement: 'body'
rootElement: 'body',

ng12Hybrid: true
};

0 comments on commit 7083426

Please sign in to comment.