不确定未知提供商:$ attrsProvider< - $ attrs是什么意思?

时间:2014-06-20 18:51:26

标签: angularjs karma-runner angular-ui-bootstrap karma-jasmine

运行我的Karma单元测试时遇到以下错误:

Error: [$injector:unpr] Unknown provider: $attrsProvider <- $attrs
    http://errors.angularjs.org/1.2.16/$injector/unpr?p0=%24attrsProvider%20%3C-%20%24attrs
        at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:78:12
        at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:3705:19
        at Object.getService [as get] (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3832:39)
        at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:3710:45
        at getService (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3832:39)
        at invoke (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3859:13)
        at Object.instantiate (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3880:23)
        at /home/ubuntu/vantage/core/static/core/js/lib/angular.js:7134:28
        at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:12:20)
        at Object.invoke (/home/ubuntu/vantage/core/static/core/js/lib/angular.js:3869:17)
    Error: Declaration Location
        at window.inject.angular.mock.inject (/home/ubuntu/vantage/core/static/core/js/lib/angular-mocks.js:2132:25)
        at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:10:20)
        at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:5:5)
        at /home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:3:1
    TypeError: Cannot call method 'expectGET' of undefined
        at null.<anonymous> (/home/ubuntu/vantage/ecommerce/js_tests/unit/progress/progressControllersSpec.js:380:18)
Chrome 33.0.1750 (Linux): Executed 42 of 45 (1 FAILED) (0 secs / 0.483 secs)
Chrome 33.0.1750 (Linux) Unit Test: ProgressController ProgressController should expect showDetailedSection to be false on initialization FAILED
    Error: [$injector:unpr] Unknown provider: $attrsProvider <- $attrs

任何人都知道这意味着什么以及如何解决它?

谢谢:)

1 个答案:

答案 0 :(得分:5)

对此的解决方案最终变得非常模糊。

问题是bootstrap-ui包实际上有一个ProgressController。所以我们的控制器被踩了。测试试图创建我们的ProgressController的实例,但结果是来自bootstrap-ui的实例。

只需重命名我们的控制器修复所有内容。