0

I'm using grunt, karma (singleRun: false). My tests are written in coffeescript. Each time my coffee file changes I want my tests to run. The problem is that I don't know how to make both happens. So far I discovered the watch task, I tried to add my coffee thing there and add the watcher to my test task like that:

//karma.conf.js
singleRun: true,

and in Gruntfile:

//Gruntfile.js
watch: {
  coffee: {
            files: ['test/spec/{,*/}*.coffee'],
            tasks: 'coffee'
        }
}
grunt.registerTask('test', [
    'clean:server',
    'coffee',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma',
    'watch:coffee'
]);

This way the karma watcher is watching javascript files, but my own coffee watcher is not triggered at all.

Right now I just removed watch:coffee from test task and I'm running grunt test and grunt watch:coffee in parallel terminals, which looks a bit pathetic. Is there a better way?

ganqqwerty
  • 1,894
  • 2
  • 23
  • 36

1 Answers1

0

Much better approach is to use the karma-coffee-preprocessor. It's simple to set up and I can use singleRun: true.

ganqqwerty
  • 1,894
  • 2
  • 23
  • 36