Skip to content
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

Support Angular4 Testability #49

Closed
ahofman opened this issue Jun 29, 2017 · 5 comments
Closed

Support Angular4 Testability #49

ahofman opened this issue Jun 29, 2017 · 5 comments

Comments

@ahofman
Copy link

ahofman commented Jun 29, 2017

When integrating ldclient-js with an Angular4 application, the Angular4 Testability service is not usable as the testability never becomes stable after an ldclient is initialized.

For example, window.getAllAngularTestabilities()[0].isStable() is always false.

The testability is considered "stable" when there are no "macro tasks" still pending. According to this, The setTimeout calls used by the ld client are macro tasks, and because the ld client uses an infinite loop of setTimeout calls there is always a macro task pending, and therefore the testability is never stable.

A similar issue exists when using angular-google-maps with the testability service: sebholstein/angular-google-maps#815

I'm no JS expert so I'm not sure how this could be solved - do we need a separate client library that specifically targets Angular4?

@MartinNuc
Copy link

I am wondering - would mocking your LD service help?

eli-darkly added a commit that referenced this issue May 26, 2018
summary events (4): break HTTP logic out of event processor, add tests for both
@jemerald
Copy link

Unfortunately, no.

Angular Testability is for e2e tests (using frameworks such as protractor), so mocking the LD service is not really an option.

@jemerald
Copy link

My current workaround is to add backdoor hooks in my LD service that check special flags in localStorage and not initialise launch-darkly client.

So before all the tests I'll need to:

  1. open application
  2. set flag in localStorage
  3. refresh browser (so that the hook is applied)

It would be awesome if the library can be enhanced to play nice with Angular Testability

@mpienkowski
Copy link

It works fine if you initialize Launch Darkly outside of Angular (in callback of NgZone#runOutsideAngular())

@bwoskow-ld
Copy link
Member

Hi all,

We don't currently have any Angular-specific support in our JavaScript SDK and we don't have any plans to change this. Consequently I'm going to close this issue now; I'm hopeful that @mpienkowski's solution works for others.

Cheers,
Ben
Engineering Manager, LaunchDarkly

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

No branches or pull requests

5 participants