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

feat(hybrid): set ng12hybrid flag in the config #3452

Merged
merged 1 commit into from
Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
};