Skip to content

Sample e2e test #33

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions e2e/src/app.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
import { AppPage } from './app.po';
import { browser, ExpectedConditions } from 'protractor';

describe('workspace-project App', () => {
describe('Trivial test example', () => {
let page: AppPage;

beforeEach(() => {
page = new AppPage();
});

it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to ng2-stompjs-angular7!');
it('Send and receive a message', async () => {
await page.navigateTo();
await browser.wait(ExpectedConditions.textToBePresentInElement(page.getStatusLabel(), 'OPEN'), 5000);

await page.getSendMessageBtn().click();

await browser.wait(ExpectedConditions.presenceOf(page.getMessageNode()), 2000);

expect(await page.getMessageNode().getText()).toContain('Message');
});
});
12 changes: 10 additions & 2 deletions e2e/src/app.po.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,15 @@ export class AppPage {
return browser.get('/');
}

getParagraphText() {
return element(by.css('app-root h1')).getText();
getStatusLabel() {
return element(by.id('status-label'));
}

getMessageNode() {
return element(by.css('#messages ol li.message'));
}

getSendMessageBtn() {
return element(by.css('#messages button'));
}
}
586 changes: 411 additions & 175 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.1"
8 changes: 8 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { interval } from 'rxjs';

@Component({
selector: 'app-root',
@@ -7,4 +8,11 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'ng2-stompjs-angular7';

constructor() {
// Uncomment following line to break e2e test,
// since it will wait forever for this interval to finish

// interval(500).subscribe();
}
}