相关疑难解决方法(0)

jasmine angularjs testing - 参数'PhoneListCtrl'不是函数,未定义

运行angularjs + Jasmine + Karma测试时,出现以下错误: 在此输入图像描述

我的测试脚本是:

describe('PhoneCat controllers', function() {

  describe('PhoneListCtrl', function(){

    it('should create "phones" model with 3 phones', inject(function($controller) {
      var scope = {},
          ctrl = $controller('PhoneListCtrl', { $scope: scope });

      expect(scope.phones.length).toBe(3);
    }));
  });
});
Run Code Online (Sandbox Code Playgroud)

这段代码只是官方AngularJS教程的副本:http: //code.angularjs.org/1.2.0-rc.3/docs/tutorial/step_02

这是我的karma.conf.js文件的一部分:

// list of files / patterns to load in the browser
files: [

    'js/bower_components/angular/angular.js',
    'js/bower_components/angular/ngular-mocks.js',
    'js/app/controllers.js',
    'test/unit/*.js'
],
Run Code Online (Sandbox Code Playgroud)

错误是PhoneListCtrl没有定义,但我相信它是在上面的代码中定义和加载的.您认为这个问题是什么?谢谢!

jasmine angularjs karma-runner

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

angularjs ×1

jasmine ×1

karma-runner ×1