Jasmine 观察者不在呼噜声中工作
你好,我正在尝试设置一个grunt的观察者,但我得到的只是控制台中的这个 $grunt watchTest 运行“监视”任务 等待$ 因此,没有实际的等待。我已经尝试了茉莉花任务,它的工作如预期。我错过了什么Jasmine 观察者不在呼噜声中工作,jasmine,gruntjs,grunt-contrib-watch,Jasmine,Gruntjs,Grunt Contrib Watch,你好,我正在尝试设置一个grunt的观察者,但我得到的只是控制台中的这个 $grunt watchTest 运行“监视”任务 等待$ 因此,没有实际的等待。我已经尝试了茉莉花任务,它的工作如预期。我错过了什么 module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), uglify: {
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/main.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
jasmine : {
src : 'src/**/*.js',
options : {
specs : 'src/test/specs/**/*.js'
}
},
watch: {
src : 'src/**/*.js',
tasks: ['jasmine']
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['uglify']);
grunt.registerTask('test', ['jasmine']);
grunt.registerTask('watchTest', ['watch']);
};
module.exports=函数(grunt){
//项目配置。
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
丑陋的:{
选项:{
横幅:'/*!*/\n'
},
建造:{
src:'src/main.js',
dest:'build/.min.js'
}
},
茉莉花:{
src:'src/***.js',
选项:{
规格:“src/test/specs/***.js”
}
},
观察:{
src:'src/***.js',
任务:[“茉莉花”]
}
});
//加载提供“丑”任务的插件。
grunt.loadNpmTasks(“grunt-contrib-uglify”);
grunt.loadNpmTasks(“grunt-contrib-jasmine”);
grunt.loadNpmTasks(“grunt-contrib-watch”);
//默认任务。
registerTask('default',['uglify']);
注册任务('test',['jasmine']);
registerTask('watchTest',['watch']);
};
您的手表配置不正确;用这个替换它:
watch: {
jasmine: {
files: ['src/**/*.js'],
tasks: ['jasmine']
}
}
另外,您不需要向alias注册任务,只需监视自己;运行grunt watch
将获得相同的结果。希望这有帮助