Tests in AngularJS: Reference error of the inject function

后端 未结 2 2036
無奈伤痛
無奈伤痛 2021-02-18 23:19

I try to test the code below:

describe(\'myService test\', function () {
    describe(\'when I call myService.one\', function () {
        beforeEach(angular.mod         


        
2条回答
  •  天命终不由人
    2021-02-19 00:00

    The line where you have

    beforeEach(angular.module('TargetMarketServices'));
    

    should be

    beforeEach(module('TargetMarketServices'));
    

    If you take a look at the angular-phonecat project in test/unit/directivesSpec.js it uses

    beforeEach(module('myApp.directives'));
    

    If I modify it to use angular.module instead:

    beforeEach(angular.module('myApp.directives'));
    

    then I get this error when running testacular also:

    TypeError: 'undefined' is not a function (evaluating 'this.func.apply(this.spec)')
    

提交回复
热议问题