Grunt config watch and karma: unit in one task

I currently have the following Gruntfile configuration with two separate tasks, and it works fine:

grunt.registerTask('server', [ 'connect', 'jshint', 'less:dev', 'watch' ]); grunt.registerTask('test', [ 'karma:unit' ]); 

I would like to do one task that will cover both things and go into one terminal window. Sort of:

 grunt.registerTask('dev', [ 'connect', 'jshint', 'less:dev', 'karma:unit', 'watch' ]); 

The problem is that karma and watches cannot work together. I tried installing karma:unit:run in watch config, and it works, but it loads the karma configuration every time the file changes. And I don't like this thing:

 Running "karma:unit:run" (karma) task [2014-05-25 01:40:24.466] [DEBUG] config - Loading config /Users/.../test/karma.config.js PhantomJS 1.9.7 (Mac OS X): Executed 4 of 4 SUCCESS (0.011 secs / 0.012 secs) 

Is there any way to solve this problem or is it better to complete these tasks separately?

+6
source share
1 answer

Use grunt-concurrent to run tasks of both hours and karma:

 concurrent: { target: { tasks: ['karma:unit', 'watch'] } } 

Then run the parallel task from your dev task:

 grunt.registerTask('dev', [ 'connect', 'jshint', 'less:dev', 'concurrent:target' ]); 
+4
source

Source: https://habr.com/ru/post/969813/


All Articles