Angular Unit test fails when i try to inject a service

醉酒当歌 提交于 2019-12-06 05:47:45

Most probably you have a dependency issue -maybe a module that cannot be loaded- but you can't tell exactly which one because PhantomJS sometimes hides relevant info from the error message.

The solution is to change (temporarily) the testing browser to Chrome or any other non-headless browser to see exactly what's wrong.

eg: you should change in Karma config or Gruntfile.js or what have you:

the line browsers: ['PhantomJS'],

into something like: browsers: ['Chrome'],

and then you should be able to see the error and correct it. Afterwards, you can switch it back to PhantomJS.

Note: Just placing for posterity the workaround as per @snowe2010's comment (the question didn't have an answer so people may disregard the solution)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!