0

Hello I am trying to set up a watcher with grunt but all I get is this in the console.

$ grunt watchTest

Running "watch" task

Waiting...$

So the there is no actual waiting. I have tried the jasmine task and it works as expected. What I have I missed?

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']);

};
pethel
  • 5,397
  • 12
  • 55
  • 86

1 Answers1

1

Your watch config is incorrect; replace it with this one:

watch: {
    jasmine: {
        files: ['src/**/*.js'],
        tasks: ['jasmine']
    }
}

Plus, you don't need to register a task to alias just watch itself; running grunt watch will achieve the same result. Hope this helps.

Ben
  • 10,106
  • 3
  • 40
  • 58