Skip to content

Commit

Permalink
feat(@schematics/angular): generate E2E tests with native promise sup…
Browse files Browse the repository at this point in the history
…port

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.
  • Loading branch information
clydin committed Oct 5, 2020
1 parent d4eaab2 commit 0bdea8d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports.config = {
browserName: 'chrome'
},
directConnect: true,
SELENIUM_PROMISE_MANAGER: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('workspace-project App', () => {
page = new AppPage();
});

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

afterEach(async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/schematics/angular/e2e/files/src/app.po.ts.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { browser, by, element } from 'protractor';

export class AppPage {
navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl) as Promise<unknown>;
async navigateTo(): Promise<unknown> {
return browser.get(browser.baseUrl);
}

getTitleText(): Promise<string> {
return element(by.css('<%= rootSelector %> .content span')).getText() as Promise<string>;
async getTitleText(): Promise<string> {
return element(by.css('<%= rootSelector %> .content span')).getText();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"devDependencies": {
"@angular/cli": "<%= '~' + version %>",
"@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %>
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",<% } %>
"@types/jasmine": "~3.5.0",<% } %>
"@types/node": "^12.11.1",<% if (!minimal) { %>
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
Expand Down

0 comments on commit 0bdea8d

Please sign in to comment.