Angularjs 测试角度UI引导';指令';是必需的

Angularjs 测试角度UI引导';指令';是必需的,angularjs,angular-ui,karma-runner,Angularjs,Angular Ui,Karma Runner,我试图对使用Angular UI Bootstrap dialog指令的控制器进行单元测试,但收到一个错误:参数'directive'是必需的错误 实际上,当我在TestCular配置中包含ui bootstrap.min.js文件时,就会发生这种情况 控制器定义为: angular.module('xFormsEntries') .controller('xFormsEntryListCtrl', function ($scope, $dialog, Form, FormEntry,

我试图对使用Angular UI Bootstrap dialog指令的控制器进行单元测试,但收到一个错误:参数'directive'是必需的错误

实际上,当我在TestCular配置中包含
ui bootstrap.min.js
文件时,就会发生这种情况

控制器定义为:

angular.module('xFormsEntries')
    .controller('xFormsEntryListCtrl', function ($scope, $dialog, Form, FormEntry, FormField) {...
单元测试是:

describe('xForms Controllers', function() {

    beforeEach(function() {
        this.addMatchers({
            toEqualData: function(expected) {
                return angular.equals(this.actual, expected);
            }
        });
    });

    beforeEach(module('xFormsServices'));
    beforeEach(module('xFormsEntries'));

    describe('xFormsEntryListCtrl', function() {
        var scope, ctrl, $httpBackend, $dialog;
        var formData = {formId: 1, name: 'FormName'};

        apiURL = ''; // Override the global API URL

        beforeEach(inject(function(_$httpBackend_, $rootScope, $controller, _$dialog_) {
            // Arrange
            $httpBackend = _$httpBackend_;
            $httpBackend.expectGET('/xFormsAPI/Form').respond(formData);

            $dialog = _$dialog_;

            scope = $rootScope.$new();
            scope.formId = 1;
            ctrl = $controller('xFormsEntryListCtrl', {$scope: scope});
        }));

        it('should fetch the form from the server', function () {
            expect(scope.formModel).toBe(undefined);
            $httpBackend.flush();
            expect(scope.formModel).toEqualData(formData);
        });
});
在集成UI引导之前,所有测试都通过了

我尝试在每个模块(模块('ui.bootstrap')之前添加
,以及其他变体,在没有运气的情况下进入测试


我缺少了什么神奇的东西来完成这项工作?

您是否包括了依赖项以及实际的js文件

装置 下载并包含在页面中的所有文件一经下载,您只需在ui.bootstrap模块上声明一个依赖项:

angular.module('myModule', ['ui.bootstrap']);

您的主模块声明是什么样子的?