为什么我收到声明例外?

时间:2014-12-02 14:15:02

标签: angularjs jasmine

我在VS 2013中运行jasmine 2.0,其中resharper作为测试运行者。

我有一个app.js文件:

var app = angular.module('app', ["navigation"]);

我已将它们包含在我的控制器中:

angular.module('navigation', []).controller('NavigationCtrl', function($scope) {
    $scope.tabs = [
        { title: 'First Tab', content: 'Controllers\FirstTab' }
    ];
});

Spec Runner文件:

<title>Jasmine Spec Runner</title>

<link rel="shortcut icon" type="image/png" href="/Content/jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="/Content/jasmine/jasmine.css">
<script type="text/javascript" src="/Scripts/jasmine/jasmine.js"></script>
<script type="text/javascript" src="/Scripts/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="/Scripts/jasmine/boot.js"></script>
<script type="text/javascript" src="/Scripts/angular.js"></script>
<script type="text/javascript" src="/Scripts/angular-mocks.js"></script>


<!-- include source files here... -->
<script type="text/javascript" src="/App/app.js"></script>
<script type="text/javascript" src="/App/Controllers/NavigationController.js"></script>

<!-- include spec files here... -->
<script type="text/javascript" src="/JSTests/NavigationControllerTests.js"></script>

然后我的测试:

describe("NavigationCtrl", function () {
    var scope;
    var controller;

    beforeEach(module('app', 'navigation'));

    beforeEach(inject(function ($rootScope, $controller) {
        scope = $rootScope.$new();
        controller = $controller('NavigationCtrl', {$scope: scope});
        }));

    it("should contain a list of tabs", function () {
        expect(scope.tabs[0].title).toBe('FirstTab');
    });
});

我收到错误:

 NavigationController encountered a declaration exception

我是角度和茉莉花测试的新手(不是单元测试),我无法看到我缺少的第一次测试工作。

有什么建议吗?

更新1。

基于评论更新代码库

0 个答案:

没有答案