Closed ahofman closed 4 years ago
I am wondering - would mocking your LD service help?
Unfortunately, no.
Angular Testability is for e2e tests (using frameworks such as protractor), so mocking the LD service is not really an option.
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:
It would be awesome if the library can be enhanced to play nice with Angular Testability
It works fine if you initialize Launch Darkly outside of Angular (in callback of NgZone#runOutsideAngular()
)
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
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 ofsetTimeout
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: https://github.com/SebastianM/angular-google-maps/issues/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?