Skip to content

bug(testing) Protractor stops working when service uses socket.io #11853

@choeller

Description

@choeller

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

It's not possible to implement e2e tests with protractor when using socket.io in the application. We are having a service, that is connecting to a websocket like this:

export class TaskService {

  socket: SocketIOClient.Socket;

  constructor(private http: Http) {
    this.socket = io(WEB_SOCKET_URL);
  }
}

just calling the io function makes protactor stop working. so my tests fails with:

[10:58:04] I/direct - Using FirefoxDriver directly...
[10:58:04] I/launcher - Running 1 instances of WebDriver
Spec started

  my-project App
    ✗ should display message saying app works
      - Failed: Timed out waiting for Protractor to synchronize with the page after 110002ms. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
While waiting for element with locator - Locator: By(css selector, h1)

**************************************************
*                    Failures                    *
**************************************************

1) my-project App should display message saying app works
  - Failed: Timed out waiting for Protractor to synchronize with the page after 110002ms. Please see https://github.com/angular/protractor/blob/master/docs/faq.md
While waiting for element with locator - Locator: By(css selector, h1)

as soon as I disconnect from the socket by doing:

export class TaskService {

  socket: SocketIOClient.Socket;

  constructor(private http: Http) {
    this.socket = io(WEB_SOCKET_URL);
    this.socket.disconnect();
  }
}

all tests are running fine.
There are also already other people experiencing the same problem:
http://stackoverflow.com/questions/39162553/running-e2e-test-using-protractor-with-angular2-and-socket-io

Expected behavior

It should be possible to run e2e tests for applications using socket.io.

Reproduction of the problem

See this repo to see the error in action: https://github.com/choeller/quickstart

What is the motivation / use case for changing the behavior?

Being able to test our application ;)

Please tell us about your environment:

  • Angular version: 2.0
  • Browser: [all]
  • Language: [TypeScript]

//cc @juliemr

Metadata

Metadata

Assignees

Labels

area: testingIssues related to Angular testing features, such as TestBedtype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions