Skip to content

feat(@angular/cli): migrate e2e tests to async/await #15472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ import { createArchitect, host, veEnabled } from '../utils';
'e2e/app.e2e-spec.ts': `
import { browser, by, element } from 'protractor';

it('should have ngsw in normal state', () => {
browser.get('/');
it('should have ngsw in normal state', async () => {
await browser.get('/');
// Wait for service worker to load.
browser.sleep(2000);
browser.waitForAngularEnabled(false);
browser.get('/ngsw/state');
await browser.sleep(2000);
await browser.waitForAngularEnabled(false);
await browser.get('/ngsw/state');
// Should have updated, and be in normal state.
expect(element(by.css('pre')).getText()).not.toContain('Last update check: never');
expect(element(by.css('pre')).getText()).toContain('Driver state: NORMAL');
expect(await element(by.css('pre')).getText()).not.toContain('Last update check: never');
expect(await element(by.css('pre')).getText()).toContain('Driver state: NORMAL');
});
`,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { SpecReporter } = require('jasmine-spec-reporter');
* @type { import("protractor").Config }
*/
exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('hello-world-app App', () => {
page = new AppPage();
});

it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to app!');
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getTitleText()).toEqual('Welcome to app!');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { SpecReporter } = require('jasmine-spec-reporter');
const { resolve } = require('path');

exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe('hello-world-app App', () => {
page = new AppPage();
});

it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to app!');
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getTitleText()).toEqual('Welcome to app!');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const { SpecReporter } = require('jasmine-spec-reporter');
const { resolve } = require('path');

exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: ['./e2e/**/*.e2e-spec.ts'],
capabilities: {
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/assets/1.0-project/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('one-oh-project App', () => {
page = new OneOhProjectPage();
});

it('should display message saying app works', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('app works!');
it('should display message saying app works', async () => {
await page.navigateTo();
expect(await page.getParagraphText()).toEqual('app works!');
});
});
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/assets/1.0-project/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/assets/1.7-project/e2e/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('latest-project App', () => {
page = new AppPage();
});

it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
it('should display welcome message', async () => {
await page.navigateTo();
expect(await page.getParagraphText()).toEqual('Welcome to app!');
});
});
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/assets/1.7-project/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { browser, logging, element, by } from 'protractor';

describe('workspace-project App', () => {
it('should display lazy route', () => {
browser.get(browser.baseUrl + '/lazy');
expect(element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
});

afterEach(async () => {
Expand Down
1 change: 1 addition & 0 deletions tests/legacy-cli/e2e/assets/protractor-saucelabs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports.config = {
sauceUser: process.env['SAUCE_USERNAME'],
sauceKey: process.env['SAUCE_ACCESS_KEY'],

SELENIUM_PROMISE_MANAGER: false,
allScriptsTimeout: 11000,
specs: ['./src/**/*.e2e-spec.ts'],

Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/build/lazy-load-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export default async function () {
import { browser, logging, element, by } from 'protractor';

describe('workspace-project App', () => {
it('should display lazy route', () => {
browser.get(browser.baseUrl + '/lazy');
expect(element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
it('should display lazy route', async () => {
await browser.get(browser.baseUrl + '/lazy');
expect(await element(by.css('app-lazy-comp p')).getText()).toEqual('lazy-comp works!');
});

afterEach(async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/legacy-cli/e2e/tests/build/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default async function () {
import { browser, logging } from 'protractor';
describe('worker bundle', () => {
it('should log worker messages', async () => {
const page = new AppPage();;
page.navigateTo();
const page = new AppPage();
await page.navigateTo();
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs.length).toEqual(1);
expect(logs[0].message).toContain('page got message: worker response to hello');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export default async function () {
page = new AppPage();
});

it('should display text from library component', () => {
page.navigateTo();
expect(element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!');
it('should display text from library component', async () => {
await page.navigateTo();
expect(await element(by.css('lib-my-lib p')).getText()).toEqual('my-lib works!');
});

afterEach(async () => {
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/misc/live-reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ export default function temporarilyDisabledTest() { return Promise.resolve(); }
// import { browser } from 'protractor';

// describe('master-project App', function() {
// it('should wait', _ => {
// browser.get('/');
// browser.sleep(30000);
// it('should wait', async _ => {
// await browser.get('/');
// await browser.sleep(30000);
// });
// });
// `,
Expand Down
6 changes: 3 additions & 3 deletions tests/legacy-cli/e2e/tests/misc/minimal-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default function () {
import { browser, element, by } from 'protractor';

describe('minimal project App', function() {
it('should display message saying app works', () => {
it('should display message saying app works', async () => {
browser.ignoreSynchronization = true;
browser.get('/');
let el = element(by.css('app-root h1')).getText();
await browser.get('/');
let el = await element(by.css('app-root h1')).getText();
expect(el).toEqual('app works!');
});
});
Expand Down
18 changes: 9 additions & 9 deletions tests/legacy-cli/e2e/tests/misc/third-party-decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export default function () {
page = new AppPage();
});

it('should operate counter', () => {
page.navigateTo();
page.getIncrementButton().click();
page.getIncrementButton().click();
expect(page.getCounter()).toEqual('2');
page.getDecrementButton().click();
expect(page.getCounter()).toEqual('1');
page.getResetButton().click();
expect(page.getCounter()).toEqual('0');
it('should operate counter', async () => {
await page.navigateTo();
await page.getIncrementButton().click();
await page.getIncrementButton().click();
expect(await page.getCounter()).toEqual('2');
await page.getDecrementButton().click();
expect(await page.getCounter()).toEqual('1');
await page.getResetButton().click();
expect(await page.getCounter()).toEqual('0');
});
});
`,
Expand Down