My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Testing { Angular 2 + Webpack + Karma + Jasmine + ng2-Translate }

VignesH KumaR's photo
VignesH KumaR
·Jun 23, 2016

Hi HashNoders.,

I have an Angular 2 ( Typescript + Webpack + Karma + Jasmine ) application and it has some basic test cases running green.

After sometime of browsing, ng2-translate seems the best library for Angular 2 Translation as of now, until Angular Team comes up with their own.

Translation worked perfect for me with that library. But, all my unit tests are blood red now :(

I am not clear on how to mock/provide Dependency Injection of the Translation Service in each Component's constructor and Translation Pipes in templates. I wanted to know how to do this, in general as well.

(The link to the library has some sample code on usage and stuffs, but not on how to unit test.)

Appreciate your help in advance.