1
我知道如何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中並正確加載,但運行功能僅在執行之後執行。
如何讓業力等待運行階段,以便在執行測試之前加載模板?