Angular 2 Unit Tests with PhantomJS - Dependency Injection not Working

Georg Dangl by Georg Dangl in Web Development Monday, August 29, 2016

Monday, August 29, 2016

Posted in Angular2

So today I encountered a little bug while upgrading Angular 2 from RC4 to RC5. When I ran my unit tests in Chrome, everything was working fine. However, with the Chutzpah Visual Studio Extension I kept receiving Error: Can't resolve all parameters for HeroService: (?) when running tests, even though the configuration seemed fine.

Chutzpah Error Message in Visual Studio for non-working Angular 2 Dependency Injection

Turns out it was PhantomJS not being fully compatible to ECMAScript 6, so I needed to include es6-shim in my npm package.json file and add it as the first reference in chutzpah.json.

I hope I can save you a bit of searching for the cause with this post. Happy testing!

Share this post

comments powered by Disqus

About me

Hi, my name's George! I love coding and blogging about it. I focus on all things around .Net, Web Development and DevOps.


Need a consultant for BIM, GAEB or Software Development?

Contact me at [email protected], +49 (173) 56 45 689 or visit my professional page!

// Just 💗 Coding

Social Links