angularjs - 睾丸 : encountered a declaration exception

标签 angularjs jasmine karma-runner

我在 angular.js 中定义了一个空模块:

angular.module('todoList', [], function () {

})

然后我想在我的 conf.js 中测试它,我加载这些javascript:
files = [
  JASMINE,
  JASMINE_ADAPTER,
  // lib
  '../js/lib/angular.min.js',
  '../js/lib/jquery-1.9.1.min.js',

  // our app
  '../js/project.js',

  // test file
  "test/*.js"
];

然后我想在测试文件中测试它:
describe('My own function', function(){
    beforeEach(module('todoList'));
});

但这一步告诉我
FAILED My own function encountered a declaration exception
我不明白为什么只是一个加载模块语句会导致错误

我该如何解决这个问题?

最佳答案

尝试在配置文件中包含 angular-mocks.js。

关于angularjs - 睾丸 : encountered a declaration exception,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15739763/

相关文章:

javascript - 当我在 Controller 的函数中传递它时未定义的字符串

unit-testing - 在 Angular 中对 $sce.trustAsHtml 的输出进行单元测试

javascript - Jasmine + AngularJS : How to test $rootScope. $broadcast 被调用参数?

Angular + (Jasmine/Karma) - 错误 : Illegal state: Could not load the summary for directive

angularjs - Webstorm karma/jasmine angularjs 测试 - 引用错误模块未定义

javascript - 在悬停时将按钮覆盖添加到链接图像

javascript - Chart.js 无法在 Heroku 上正确部署

javascript - 类型错误 : Cannot read property 'then' of undefined in testing AngularJS controller with Karma

AngularJS Jasmine 测试 get-request

angularjs - AngularJS 单元测试中模拟 $compileProvider 的详细信息