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

Commit 7083426

Browse files
sjelincnishina
authored andcommitted
feat(hybrid): set ng12hybrid flag in the config (#3452)
1 parent 3e4bc27 commit 7083426

File tree

6 files changed

+28
-11
lines changed

6 files changed

+28
-11
lines changed

lib/browser.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,10 @@ export class ProtractorBrowser extends Webdriver {
10051005
* Create a new instance of Browser by wrapping a webdriver instance.
10061006
*
10071007
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
1008-
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
1009-
* @param {boolean=} opt_untrackOutstandingTimeouts Whether Browser should
1008+
* @param {string=} baseUrl A URL to prepend to relative gets.
1009+
* @param {string=} rootElement The css selector for the element which is the
1010+
* root of the Angular app.
1011+
* @param {boolean=} untrackOutstandingTimeouts Whether Browser should
10101012
* stop tracking outstanding $timeouts.
10111013
* @returns {Browser} a new Browser instance
10121014
*/

lib/config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ export interface Config {
567567
*/
568568
disableEnvironmentOverrides?: boolean;
569569

570+
/**
571+
* Tells Protractor to interpret any angular apps it comes across as hybrid
572+
* angular1/angular2 apps (i.e. apps using ngUpgrade)
573+
* Defaults to `false`
574+
*
575+
* @type {boolean}
576+
*/
577+
ng12Hybrid?: boolean;
578+
570579
seleniumArgs?: Array<any>;
571580
configDir?: string;
572581
troubleshoot?: boolean;

lib/configParser.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class ConfigParser {
4141
noGlobals: false,
4242
plugins: [],
4343
skipSourceMapSupport: false,
44+
ng12Hybrid: false
4445
};
4546
}
4647

lib/runner.ts

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ export class Runner extends EventEmitter {
231231
if (config.useAllAngular2AppRoots) {
232232
browser_.useAllAngular2AppRoots();
233233
}
234+
if (config.ng12Hybrid) {
235+
browser_.ng12Hybrid = config.ng12Hybrid;
236+
}
234237

235238
browser_.ready =
236239
driver.manage().timeouts().setScriptTimeout(config.allScriptsTimeout);

spec/hybrid/async_spec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
describe('async angular1/2 hybrid using ngUpgrade application', function() {
22
beforeEach(function() {
3-
browser.ng12Hybrid = true;
4-
53
browser.get('/hybrid');
64
});
75

8-
afterEach(function() {
9-
browser.ng12Hybrid = false;
10-
});
11-
12-
it('should propertly load the page', function() {
13-
expect($('h1').getText()).toEqual('My App');
6+
it('should set browser flag via config', function() {
7+
expect(browser.ng12Hybrid).toBe(true);
148
});
159

1610
it('should be able to click buttons and wait for $timeout', function() {
@@ -29,4 +23,10 @@ describe('async angular1/2 hybrid using ngUpgrade application', function() {
2923
ng1Btn.click();
3024
expect(ng1Btn.getText()).toEqual('Click Count: 1');
3125
});
26+
27+
it('should use the flag on the browser object', function() {
28+
browser.ng12Hybrid = false;
29+
browser.get('/ng2'); // will time out if Protractor expects hybrid
30+
browser.ng12Hybrid = true;
31+
});
3232
});

spec/hybridConf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ exports.config = {
1414

1515
baseUrl: env.baseUrl,
1616

17-
rootElement: 'body'
17+
rootElement: 'body',
18+
19+
ng12Hybrid: true
1820
};

0 commit comments

Comments
 (0)