【发布时间】:2016-03-17 10:44:59
【问题描述】:
我有一个基本的 angular 1.5 组件,如下所示:
angular
.module('app')
.component('techs', {
templateUrl: 'app/techs/techs.html',
controller: TechsController
});
我想只模拟这个组件而不是整个应用程序,因为angular.mock.module('app') 模拟了应用程序的每个组件。有办法吗?
我试过angular.mock.module('techs'),但出现了这个错误:
Failed to instantiate module techs due to:
Module 'techs' is not available! You either misspelled the module name or forgot to load it
【问题讨论】:
-
您忘记将其添加到 karma.conf.js 文件吗?
-
不,它就在那里。
-
你的意思是只实例化那个组件吗?为什么不想实例化整个模块?