在 Jasmine 中加载具有依赖项的模块

Loading modules with dependencies in Jasmine

本文关键字:依赖 模块 Jasmine 加载      更新时间:2023-09-26

>我有一个模块,定义如下:

var angular_multi_select_engine = angular.module('angular-multi-select-engine', [
    'angular-multi-select-constants'
]);

如您所见,engine取决于constants模块。

我正在尝试在engine上运行一些测试,带有这个:

beforeEach(function() {
    angular.mock.module('angular-multi-select-engine', 'angular-multi-select-constants');
});

但是当我尝试运行茉莉花时,它说:

Error: [$injector:modulerr] Failed to instantiate module angular-multi-select-engine due to:
[$injector:nomod] Module 'angular-multi-select-engine' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

如果我尝试仅加载constants模块,Jasmine 将按预期工作,我可以测试constants模块的值。

我应该如何加载具有依赖项的模块?

事实证明,Jasmine 没有加载 engine 模块,因为我使用了 ES6 语法。我将对此提出一个新问题。