Gruntjs 警告:任务“;“网络测试”;找不到
我不明白为什么不能在一个Gruntfile中注册这两个测试。当我运行Gruntjs 警告:任务“;“网络测试”;找不到,gruntjs,Gruntjs,我不明白为什么不能在一个Gruntfile中注册这两个测试。当我运行grunt测试时,它运行得非常好。当我运行grunt web时,它会给我警告:找不到任务“webTest”。每个任务中的代码完全相同,那么为什么grunt只允许注册一个任务呢 // Gruntfile.js module.exports = function(grunt){ // Load grunt mocha task grunt.loadNpmTasks('grunt-mocha'); grunt.loadNp
grunt测试时,它运行得非常好。当我运行grunt web
时,它会给我警告:找不到任务“webTest”
。每个任务中的代码完全相同,那么为什么grunt只允许注册一个任务呢
// Gruntfile.js
module.exports = function(grunt){
// Load grunt mocha task
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// webTest
webTest: {
test: {
options: {
reporter: 'list',
timeout: 2000
},
src: ['all.js',
'test/groups.js',
'test/doctors.js',
'test/patients.js',
'test/diet.js']
}
},
// Mocha Test
mochaTest: {
test: {
options: {
reporter: 'list',
timeout: 2000
},
src: ['all.js',
'test/groups.js',
'test/doctors.js',
'test/patients.js',
'test/diet.js']
}
}
});
grunt.registerTask('web', ['webTest']);
grunt.registerTask('test', ['mochaTest']);
};
我想出来了:
// Gruntfile.js
module.exports = function(grunt){
// Load grunt mocha task
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-contrib');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Mocha Test
mochaTest: {
test: {
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/groups.js',
'test/doctors.js',
'test/patients.js',
'test/diet.js']
},
web_enter: { // fill database for website testing
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/web_testing_enter.js']
},
web_remove: { // remove data entered for website testing
options: {
reporter: 'list',
timeout: 2000
},
src: ['test/web_testing_remove.js']
}
}
});
grunt.registerTask('we', ['mochaTest:web_enter']);
grunt.registerTask('wr', ['mochaTest:web_remove']);
grunt.registerTask('default', ['mochaTest:test']);
};