这是我的grunt文件,基本上我想启动HTTP服务器并启动量角器测试。我猜测我的语法是关闭的吗?
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
karma: {
options: {
configFile: 'www/test/karma-conf.js'
},
unit: {
singleRun: true
},
continuous: {
background: true
}
},
protractor: {
options: {
configFile: "www/test/frontend.conf.js", // Default config file
// keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
// debug: true,
args: {
}
},
e2e: {
options: {
keepAlive: false
}
},
continuous: {
options: {
keepAlive: true
}
}
},
watch: {
options: {
livereload: true
},
karma: {
files: ['www/js/**/*.js', 'www/test/unit/*.js'],
tasks: ['karma:continuous:run']
}
,
protractor: {
files: ['www/js/**/*.js', 'www/test/e2e/*.js'],
tasks: ['protractor:continuous']
}
},
run: {
mock_server: {
options: {
wait: false
},
args: ['app/mockApi/apiserver.js']
}
},
connect: {
options: {
port: 9000,
hostname: 'localhost'
},
livereload: {
options: {
livereload: 35729,
open: true,
base: ['www']
}
},
test: {
options: {
base: ['www']
}
}
}
});
//grunt.loadNpmTasks('grunt-contrib-watch');
//grunt.loadNpmTasks('grunt-contrib-connect');
//grunt.loadNpmTasks('grunt-karma');
//grunt.loadNpmTasks('grunt-protractor-runner');
//grunt.loadNpmTasks('grunt-run');
grunt.registerTask('serve', ['karma:continuous:start', 'run:mock_server', 'connect:livereload', 'watch:karma']);
grunt.registerTask('unit-test', ['karma:continuous:start', 'watch:karma']);
grunt.registerTask('e2e-test', ['connect:test', 'protractor:continuous', 'watch:protractor']);
grunt.registerTask('test', ['karma:unit:start', 'connect:test', 'run:mock_server', 'protractor:e2e']);
};

运行时我得到的是以下错误:
$ grunt e2e-test --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ e2e-test, serve, test, unit-test
Running tasks: e2e-test
Running "e2e-test" task
Warning: Task "connect:test" not found. Use --force to continue.
Aborted due to warnings.
答案 0 :(得分:1)
我相信你只需要取消注释grunt.loadNpmTasks('grunt-contrib-connect');