为什么业力不执行任何测试?
Why karma isn't executing any tests?
我创建了一个 JHipster 项目并创建了一个 javascript 规范,但是当我 运行 karma start 我得到此输出:
~/projetos/consami/src/test/javascript$ karma start
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Linux)]: Connected on socket -yuANSJ71nx8EeeomeZW with id 73836995
这是JHipster提供的配置:
module.exports = function (config) {
config.set({
basePath: '../../',
frameworks: ['jasmine'],
files: [
'main/webapp/bower_components/modernizr/modernizr.js',
'main/webapp/bower_components/jquery/dist/jquery.js',
'main/webapp/bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
'main/webapp/bower_components/json3/lib/json3.js',
'main/webapp/bower_components/angular/angular.js',
'main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js',
'main/webapp/bower_components/angular-resource/angular-resource.js',
'main/webapp/bower_components/angular-cookies/angular-cookies.js',
'main/webapp/bower_components/angular-sanitize/angular-sanitize.js',
'main/webapp/bower_components/angular-translate/angular-translate.js',
'main/webapp/bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.js',
'main/webapp/bower_components/angular-translate-loader-partial/angular-translate-loader-partial.js',
'main/webapp/bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js',
'main/webapp/bower_components/angular-local-storage/dist/angular-local-storage.js',
'main/webapp/bower_components/angular-cache-buster/angular-cache-buster.js',
'main/webapp/bower_components/angular-mocks/angular-mocks.js',
'main/webapp/scripts/app/app.js',
'main/webapp/scripts/app/**/*.js',
'main/webapp/scripts/components/**/*.js',
'test/javascript/**/!(karma.conf).js'
],
exclude: [],
port: 9876,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: false
});
};
我对业力真的很陌生,但它应该显示规范的执行情况,不是吗?
新信息
我不知道它是否正确,但是当我在 Chrome 中打开 karma 时,唯一导入 javascript 的行是:
<script src="socket.io/socket.io.js"></script>
<script src="karma.js"></script>
我可能错了,但它不应该加载文件数组中的所有文件吗?
karma start --browsers Chrome --single-run
是您要查找的内容吗?
终于找到了解决办法:
已安装 karma-jasmine-html-reporter 并执行:
karma start src/test/javascript/karma.conf.js --reporters html
现在我可以在浏览器中单击调试按钮看到测试结果。
我创建了一个 JHipster 项目并创建了一个 javascript 规范,但是当我 运行 karma start 我得到此输出:
~/projetos/consami/src/test/javascript$ karma start
INFO [karma]: Karma v0.12.31 server started at http://localhost:9876/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Linux)]: Connected on socket -yuANSJ71nx8EeeomeZW with id 73836995
这是JHipster提供的配置:
module.exports = function (config) {
config.set({
basePath: '../../',
frameworks: ['jasmine'],
files: [
'main/webapp/bower_components/modernizr/modernizr.js',
'main/webapp/bower_components/jquery/dist/jquery.js',
'main/webapp/bower_components/bootstrap-sass/assets/javascripts/bootstrap.js',
'main/webapp/bower_components/json3/lib/json3.js',
'main/webapp/bower_components/angular/angular.js',
'main/webapp/bower_components/angular-ui-router/release/angular-ui-router.js',
'main/webapp/bower_components/angular-resource/angular-resource.js',
'main/webapp/bower_components/angular-cookies/angular-cookies.js',
'main/webapp/bower_components/angular-sanitize/angular-sanitize.js',
'main/webapp/bower_components/angular-translate/angular-translate.js',
'main/webapp/bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.js',
'main/webapp/bower_components/angular-translate-loader-partial/angular-translate-loader-partial.js',
'main/webapp/bower_components/angular-dynamic-locale/src/tmhDynamicLocale.js',
'main/webapp/bower_components/angular-local-storage/dist/angular-local-storage.js',
'main/webapp/bower_components/angular-cache-buster/angular-cache-buster.js',
'main/webapp/bower_components/angular-mocks/angular-mocks.js',
'main/webapp/scripts/app/app.js',
'main/webapp/scripts/app/**/*.js',
'main/webapp/scripts/components/**/*.js',
'test/javascript/**/!(karma.conf).js'
],
exclude: [],
port: 9876,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: false
});
};
我对业力真的很陌生,但它应该显示规范的执行情况,不是吗?
新信息
我不知道它是否正确,但是当我在 Chrome 中打开 karma 时,唯一导入 javascript 的行是:
<script src="socket.io/socket.io.js"></script>
<script src="karma.js"></script>
我可能错了,但它不应该加载文件数组中的所有文件吗?
karma start --browsers Chrome --single-run
是您要查找的内容吗?
终于找到了解决办法:
已安装 karma-jasmine-html-reporter 并执行:
karma start src/test/javascript/karma.conf.js --reporters html
现在我可以在浏览器中单击调试按钮看到测试结果。