Jake Smith
Jake Smith

Reputation: 2813

ng e2e test timesout

Problem

My e2e test stopped working some time ago with no changes made to it. I don't know why it is timing out, and I'm not sure how to diagnose this myself. I have learned that the code in my test is actually a Promise that gets run when Angular is ready, and not knowing this earlier incorrectly led me to believe that the problem I was having was that my test was running before Angular was ready.

Now I have a .then(...) and a .catch(...) on my page.getParagraphText() call to see what is eventually going on. After 30 seconds (I've increased how long it is willing to wait), it errors out with a timeout error. I've gone to the url it suggests and tried anything that seemed related, to no avail.

Version

$ ng version

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.3
Node: 8.9.4
OS: win32 x64
Angular: 5.1.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router, service-worker

@angular/cli: 1.6.3
@angular/language-service: 4.4.6
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0

Screenshot

debug screen shot

My protractor configuration matches any new Angular CLI project that I create and those new ones that I generate have no problem with their e2e tests. I haven't changed my applications default e2e test that I started with, but sure would like to begin writing more tests in the e2e space.

At first, I thought that the browser wasn't being captured as I have had that error come up before. But as soon as I figured out how to debug e2e tests in vs code, I noticed this isn't the same issue as I've seen in the past.

Question

How do I diagnose what the hang up is? Are there fairly common reasons for these tests to timeout?

app.po.ts

import { browser, by, element } from 'protractor'; 

export class TDPortalPage { 
    navigateTo() { return browser.get('/'); } 

    getParagraphText() { 
        return element(by.css('header.header > div.header-content > div.header-logo > a.logo > span.header-title')).getText(); 
    } 
}

Update

I'm still having this issue. One other thing I've learned is that as soon as I resize the window that comes up during e2e testing, the tests run immediately. But I don't want to have to manually resize the window for each test run, obviously. But does that hint at what the issue could be?

In other words, if I do this to each test, they run:

import { browser } from 'protractor';

import { TDPortalPage } from './app.po';

describe('tdportal App', () => {
  let page: TDPortalPage;

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

  it('should display message saying Title', () => {
    page.navigateTo()
      // THIS IS WHAT ALLOWS MY TEST TO RUN.  BUT I HAVE TO DO IT TO EACH TEST.
      .then(_ => browser.manage().window().setSize(800, 600));
    expect(page.getParagraphText()).toEqual('Title');
  });
});

Upvotes: 2

Views: 1386

Answers (1)

yong
yong

Reputation: 13722

Look into protractor offical website about TimeOut: http://www.protractortest.org/#/timeouts

enter image description here

exports.config = {

    allScriptsTimeout: (30 * 1000),

Upvotes: 1

Related Questions