Skip to content

Commit

Permalink
async/await e2e and disable selenium promise manager (closes #399)
Browse files Browse the repository at this point in the history
  • Loading branch information
captaincaius committed Jan 6, 2019
1 parent b535d22 commit 3dabf4f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions generators/app/templates/e2e/_protractor.conf.js
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
20 changes: 10 additions & 10 deletions generators/app/templates/e2e/src/_app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ describe('when the app loads', () => {
const app = new AppSharedPage();
const shell = new ShellPage();

beforeAll(() => {
app.navigateAndSetLanguage();
beforeAll(async () => {
await app.navigateAndSetLanguage();
});

<% if (props.auth) { -%>
it('should display the login page', () => {
expect(browser.getCurrentUrl()).toContain('/login');
it('should display the login page', async () => {
expect(await browser.getCurrentUrl()).toContain('/login');
});

<% } else { -%>
it('should display the shell page', () => {
expect(browser.getCurrentUrl()).toContain('/');
it('should display the shell page', async () => {
expect(await browser.getCurrentUrl()).toContain('/');
});

<% } -%>
<% if (props.auth) { -%>
describe('and the user logs in', () => {
beforeAll(() => {
login.login();
beforeAll(async () => {
await login.login();
});

<% } else { -%>
describe('and the page loads', () => {
<% } -%>
it('should display the hello message', () => {
expect(shell.getParagraphText()).toEqual('Hello world !');
it('should display the hello message', async () => {
expect(await shell.getParagraphText()).toEqual('Hello world !');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export class LoginPage {
constructor() {
}

login() {
this.usernameField.sendKeys('test');
this.passwordField.sendKeys('123');
this.loginButton.click();
async login() {
await this.usernameField.sendKeys('test');
await this.passwordField.sendKeys('123');
await this.loginButton.click();
}
}
10 changes: 5 additions & 5 deletions generators/app/templates/e2e/src/page-objects/_app-shared.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export class AppSharedPage {
constructor() {
}

navigateAndSetLanguage() {
async navigateAndSetLanguage() {
// Forces default language
this.navigateTo();
browser.executeScript(() => localStorage.setItem('language', 'en-US'));
await this.navigateTo();
await browser.executeScript(() => localStorage.setItem('language', 'en-US'));
}

navigateTo() {
return browser.get('/');
async navigateTo() {
await browser.get('/');
}
}
4 changes: 2 additions & 2 deletions generators/app/templates/e2e/src/page-objects/_shell.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ShellPage {
constructor() {
}

getParagraphText() {
return this.welcomeText.getText();
async getParagraphText() {
return await this.welcomeText.getText();
}
}

0 comments on commit 3dabf4f

Please sign in to comment.