diff --git a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts
index 903691f898..692d67c27c 100644
--- a/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts
+++ b/aio/content/examples/component-interaction/e2e/src/app.e2e-spec.ts
@@ -2,11 +2,7 @@ import { browser, element, by } from 'protractor';
describe('Component Communication Cookbook Tests', () => {
- // Note: '?e2e' which app can read to know it is running in protractor
- // e.g. `if (!/e2e/.test(location.search)) { ...`
- beforeAll(() => {
- browser.get('?e2e');
- });
+ beforeAll(() => browser.get(browser.baseUrl));
describe('Parent-to-child communication', () => {
// #docregion parent-to-child
@@ -156,11 +152,11 @@ describe('Component Communication Cookbook Tests', () => {
// Can't run timer tests in protractor because
// interaction w/ zones causes all tests to freeze & timeout.
xdescribe('Parent calls child via local var', () => {
- countDownTimerTests('countdown-parent-lv');
+ countDownTimerTests('app-countdown-parent-lv');
});
xdescribe('Parent calls ViewChild', () => {
- countDownTimerTests('countdown-parent-vc');
+ countDownTimerTests('app-countdown-parent-vc');
});
function countDownTimerTests(parentTag: string) {
@@ -168,10 +164,14 @@ describe('Component Communication Cookbook Tests', () => {
// ...
it('timer and parent seconds should match', () => {
const parent = element(by.tagName(parentTag));
+ const startButton = parent.element(by.tagName('button')).get(0);
const message = parent.element(by.tagName('app-countdown-timer')).getText();
- browser.sleep(10); // give `seconds` a chance to catchup with `message`
- const seconds = parent.element(by.className('seconds')).getText();
- expect(message).toContain(seconds);
+
+ startButton.click().then(() => {
+ browser.sleep(10); // give `seconds` a chance to catchup with `message`
+ const seconds = parent.element(by.className('seconds')).getText();
+ expect(message).toContain(seconds);
+ });
});
it('should stop the countdown', () => {
diff --git a/aio/content/examples/component-interaction/example-config.json b/aio/content/examples/component-interaction/example-config.json
index 05e262817d..e69de29bb2 100644
--- a/aio/content/examples/component-interaction/example-config.json
+++ b/aio/content/examples/component-interaction/example-config.json
@@ -1,13 +0,0 @@
-{
- "tests": [
- {
- "cmd": "yarn",
- "args": [
- "e2e",
- "--protractor-config=e2e/protractor-puppeteer.conf.js",
- "--no-webdriver-update",
- "--port={PORT}"
- ]
- }
- ]
-}
diff --git a/aio/content/examples/component-interaction/src/app/app.component.html b/aio/content/examples/component-interaction/src/app/app.component.html
index 907e0181fa..88d05abdb1 100644
--- a/aio/content/examples/component-interaction/src/app/app.component.html
+++ b/aio/content/examples/component-interaction/src/app/app.component.html
@@ -30,22 +30,21 @@
{{message}}
' }) -export class CountdownTimerComponent implements OnInit, OnDestroy { +export class CountdownTimerComponent implements OnDestroy { intervalId = 0; message = ''; seconds = 11; - clearTimer() { clearInterval(this.intervalId); } - - ngOnInit() { this.start(); } ngOnDestroy() { this.clearTimer(); } start() { this.countDown(); } @@ -22,6 +19,8 @@ export class CountdownTimerComponent implements OnInit, OnDestroy { this.message = `Holding at T-${this.seconds} seconds`; } + private clearTimer() { clearInterval(this.intervalId); } + private countDown() { this.clearTimer(); this.intervalId = window.setInterval(() => {