At the moment I am running tests with simple-mocha grunt task. I want to debug the code while running the tests. How would I do that with grunt?
simplemocha: {
options: {
globals: ['expect'],
timeout: 3000,
ignoreLeaks: false,
ui: 'bdd',
reporter: 'tap'
},
all: {
src: ['test/*.js']
}
},
I can think of two ways of achieving this. One is using this grunt task as a step of your own test-debug task (does exactly the same as your simplemocha task but runs grunt-debug first): https://github.com/burnnat/grunt-debug
You must enable the plugin by adding this to your Gruntfile:
grunt.loadNpmTasks('grunt-debug');
and then prepend debug before running your existing task, in console:
grunt debug simplemocha
Or, you could invoke nodejs --debug passing the main grunt script and arguments. A convenient way to do that in Linux bash would be nodejs --debug $(which grunt) simplemocha.