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.
This commit is contained in:
Charles Lyding 2020-10-01 19:10:16 -04:00 committed by Charles
parent d4eaab2579
commit 0bdea8ddea
5 changed files with 9 additions and 10 deletions

View File

@ -16,6 +16,7 @@ exports.config = {
browserName: 'chrome'
},
directConnect: true,
SELENIUM_PROMISE_MANAGER: false,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {

View File

@ -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 () => {

View File

@ -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();
}
}

View File

@ -7,7 +7,6 @@
"target": "es2018",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}

View File

@ -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",