Karma angular unittest runner因没有明显原因失败,没有运行任何测试而只是显示(在cli中):
Chrome 30.0.1599(Linux)错误未捕获的SyntaxError:意外的令牌 <在/home/Documents/Projects/angular/app/index.html:2 Chrome 30.0.1599(Linux):执行0 0错误(0.314秒/ 0秒)
但index.html文件只是标准..它与应用程序完美运行。而“违规行”只是:
<!DOCTYPE html>
浏览器仅显示默认值:
Karma v0.10.2 - 已连接 Chrome 30.0.1599(Linux)空闲
大多数文件都来自angular-seed。我验证即使我将controllerSpec.js中的所有内容都评论为原始状态,我也会得到相同的错误消息:
这是karma.config(我试过的注释):
module.exports = function(config){
config.set({
basePath : '../',
files : [
'app/lib/angular/angular.js',
'app/lib/angular/angular-resource.js',
'test/lib/**/*.js',
'test/lib/angular/**/*.js',
// 'app/lib/bootstrap-gh-pages/assets/rainbow.js',
'app/lib/jquery/jquery.js',
// 'app/lib/**/*.js',
'app/js/**/*.js',
'test/unit/**/*.js',
'app/index.html'
],
autoWatch : true,
frameworks: ['jasmine'],
browsers : ['Chrome'], //fails with Firefox also
plugins : [
'karma-junit-reporter',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine',
'karma-coverage'
],
junitReporter : {
outputFile: 'test_out/unit.xml',
suite: 'unit'
},
reporters:['coverage','dots'], //also tried 'progress' removing 'coverage' and removing the while reporters block. nothing helped
preprocessors : {
'**/js/*.js': 'coverage'
},
//
})}
这是run-test.sh:
BASE_DIR = dirname $0
echo ""
echo "Starting Karma Server (http://karma-runner.github.io)"
echo "-------------------------------------------------------------------"
karma start $BASE_DIR/../config/karma.conf.js $*
实际上没有测试。 我看见 e2e运行脚本确实有效。
任何线索? (在ubuntu 13上运行) 我很乐意为此提供帮助!
答案 0 :(得分:2)
套件失败,因为您在文件中包含了一个html文件。 <
是一个意外的字符javascript-wise。只有javascript文件应该在文件列表中。