Karma error - Unknown provider: $$asyncCallbackProvider

孤街浪徒 提交于 2019-12-01 15:00:28

问题


Trying to run my karma test through grunt but getting an error:

Error: [$injector:modulerr] Failed to instantiate module ngMock due to:
Error: [$injector:unpr] Unknown provider: $$asyncCallbackProvider

I removed 'ngAnimate' but does not resolve it. How can I run the grunt karma test without this error?


回答1:


I had the same problem just now, and fixed it by making sure the version of my angular-mock dependancy was the same as that angular.

You can do this in your bower.json file (change "angular-mocks": "~1.3.0" to "angular-mocks": "^1.3.0" or a specific version).




回答2:


While I have no doubt that 3sdmx's answer would work, I just ran an NPM update and that worked. Thought I should mention that so that people aren't maintaining their .json files so closely.




回答3:


You should add all the angular dependencies that you used in your project to your karma.conf.js file. It seems like you need to add ngMock to your karma file, like the example below :

    files: [
         '*/**/angula-ngMock.js'
    ],


来源:https://stackoverflow.com/questions/31832947/karma-error-unknown-provider-asynccallbackprovider

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