【发布时间】:2015-03-22 16:28:05
【问题描述】:
我知道如何load templates in my karma tests using the ng-html2js preprocessor。然而,在我们的项目中,我们已经有一个 templates.js 文件,看起来像这样:
angular.module("myApp").run(
["$templateCache", function($templateCache) {
$templateCache.put(
"app/directive-template.html",
"<span>Some fancy template.</span>");
...
});
它是使用gulp-angular-templatecache 插件生成的。这对生产非常有用,但对测试失败。该文件包含在 karma.conf.js 中并正确加载,但运行函数仅在执行测试后执行。
如何让 karma 等待运行阶段,以便在执行测试之前加载模板?
【问题讨论】:
标签: angularjs templates karma-runner