Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Protractor and Stomp #133

Open
BillSheldon-HunterIndustries opened this issue Feb 14, 2019 · 5 comments
Open

Protractor and Stomp #133

BillSheldon-HunterIndustries opened this issue Feb 14, 2019 · 5 comments

Comments

@BillSheldon-HunterIndustries

We are working with the latest release of both Angular 7 and Stomp 7.2.0.
We ran into a conflict with our existing protractor tests when we upgraded from StompRService and StompConfig to RxStompService and RxStompConfig. Injecting the RxStompService into the constructor breaks the existing protractor test with the below error

`

  • Failed: script timeout: result was not received in 11 seconds
    (Session info: chrome=71.0.3578.98)
    (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)
    `

We created a new CLI project to reproduce the issue. As part of working with this solution we found that adding browser.waitForAngularEnabled(false); enabled a given test to run successfully.

Unfortunately, in our existing project, we have hundreds of tests and this workaround will not work in most instances. Since we monitor the RabbitMQ queues at the application level, we would be interested in any suggestions or a solution that allowed us to bypass this issue for our protractor tests.

Thanks
Bill & the Hunter Industries Pilot Mob

@kum-deepak
Copy link
Member

I must be honest - I have not written a single protractor test myself 😄

You have mentioned that when you used StompRService and StompConfig it used to work. Can you please check which version of @stomp/ng2-stompjs and @stomp/stompjs were in use.

Meanwhile, I will also get a shot at writing some protractor tests.

@BillSheldon-HunterIndustries
Copy link
Author

Hi Deepak,

We are using version 7.2.0 of @stomp/ng2-stompjs. We tried the e2e example that was provided in your source code (ng2-stompjs-angular7) and were able to reproduce the issue. We think it's an issue of the stomp continuously connecting to the website/queue and not giving control back to protractor. We believe that is why adding browser.waitForAngularEnabled(false) works, as it enables protractor to continue execution without angular to finish all requests.

Thank you,
Bill & the Hunter Industries Pilot Mob

@mstawick
Copy link

mstawick commented Jan 7, 2021

This seems to have worked for me (socket gets created outside angular):

export function rxStompOutsideAngularServiceFactory(rxStompConfig: InjectableRxStompConfig, ngZone: NgZone): RxStompService {
  return ngZone.runOutsideAngular(() => {
    return rxStompServiceFactory(rxStompConfig);
  });
}

and then:

{provide: RxStompService, useFactory: rxStompOutsideAngularServiceFactory, deps: [InjectableRxStompConfig, NgZone]},

Just remember that you'll need to get back to angular zone inside stomp callbacks (if needed of course). For my project, it was fairly easy, because I've already had wrappers for watch/rpc.

@kum-deepak
Copy link
Member

Wow! This is good news. Thanks! I am changing the label.

@kum-deepak
Copy link
Member

Will you be able to fork https://github.com/stomp-js/ng2-stompjs-angular7 and update it to write one simple test. If you prefer you can use the angular10 branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants