我正在使用 cg-angular 来搭建我的项目。
我正在测试一个使用 templateUr 和 ng-html2js 将我的模板加载到模块中的指令。当我使用 Chrome 作为浏览器运行测试时,它没有问题,但是当我使用 Phantom 运行它时,我得到:
Error: [$injector:modulerr] Failed to instantiate module templates due to:
这是我的 Gruntfile 的相关部分:
karma: {
options: {
frameworks: ['jasmine'],
preprocessors: {'directive/**/*.html':['ng-html2js']},
files: [ //this files data is also updated in the watch handler, if updated change there too
'<%= dom_munger.data.appjs %>',
'bower_components/angular-mocks/angular-mocks.js',
'directive/**/*.html',
createFolderGlobs(['*-spec.js'])
],
ngHtml2JsPreprocessor:{
moduleName:'templates'
},
logLevel: 'ERROR',
reporters: ['mocha'],
autoWatch: false, //watching is handled by grunt-contrib-watch
},
all_tests: {
browsers: ['PhantomJS', 'Chrome'],
singleRun:false
},
during_watch:{
browsers: ['PhantomJS'],
singleRun:true
}
}
所以运行运行 karma:all_tests 的 grunt 测试就像一个冠军。运行 karma:during_watch 的 grunt serve 失败。
有没有办法检查 html2js 是否真的在运行?
编辑 它不是幻影。如果我在“during_watch”任务中运行 Chrome,它也会失败。