Skip to content

Commit 0bdea8d

Browse files
committed
feat(@schematics/angular): generate E2E tests with native promise support
This change adjusts the E2E schematic to generate a protractor configuration with the selenium promise manager disabled. It also adjusts the generated test files to use native promises and async/await to control test execution.
1 parent d4eaab2 commit 0bdea8d

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

packages/schematics/angular/e2e/files/protractor.conf.js.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ exports.config = {
1616
browserName: 'chrome'
1717
},
1818
directConnect: true,
19+
SELENIUM_PROMISE_MANAGER: false,
1920
baseUrl: 'http://localhost:4200/',
2021
framework: 'jasmine',
2122
jasmineNodeOpts: {

packages/schematics/angular/e2e/files/src/app.e2e-spec.ts.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ describe('workspace-project App', () => {
88
page = new AppPage();
99
});
1010

11-
it('should display welcome message', () => {
12-
page.navigateTo();
13-
expect(page.getTitleText()).toEqual('<%= relatedAppName %> app is running!');
11+
it('should display welcome message', async () => {
12+
await page.navigateTo();
13+
expect(await page.getTitleText()).toEqual('<%= relatedAppName %> app is running!');
1414
});
1515

1616
afterEach(async () => {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { browser, by, element } from 'protractor';
22

33
export class AppPage {
4-
navigateTo(): Promise<unknown> {
5-
return browser.get(browser.baseUrl) as Promise<unknown>;
4+
async navigateTo(): Promise<unknown> {
5+
return browser.get(browser.baseUrl);
66
}
77

8-
getTitleText(): Promise<string> {
9-
return element(by.css('<%= rootSelector %> .content span')).getText() as Promise<string>;
8+
async getTitleText(): Promise<string> {
9+
return element(by.css('<%= rootSelector %> .content span')).getText();
1010
}
1111
}

packages/schematics/angular/e2e/files/tsconfig.json.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"target": "es2018",
88
"types": [
99
"jasmine",
10-
"jasminewd2",
1110
"node"
1211
]
1312
}

packages/schematics/angular/workspace/files/package.json.template

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
"devDependencies": {
2626
"@angular/cli": "<%= '~' + version %>",
2727
"@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %>
28-
"@types/jasmine": "~3.5.0",
29-
"@types/jasminewd2": "~2.0.3",<% } %>
28+
"@types/jasmine": "~3.5.0",<% } %>
3029
"@types/node": "^12.11.1",<% if (!minimal) { %>
3130
"codelyzer": "^6.0.0",
3231
"jasmine-core": "~3.6.0",

0 commit comments

Comments
 (0)