How to Debug Grunt Mocha Task?

穿精又带淫゛_ 提交于 2019-12-03 06:41:20
Prateek

To run grunt task in debug, you need to pass the grunt task script to node-inspector:

node-debug $(Path \AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt) task

Put a debugger; line in your task. node-inspector will then open a browser with debugging tools.

This link help you how its work grunt-node-inspector

Example: ChrisWren/grunt-node-inspector

Source: Stackoverflow Question

Finally I am able to debug my mocha tasks! Thanks for all your answers and comments, but unfortunately I have to select my own answer, because that is the only one that worked for me.

Thanks to this video I found out what I was missing: http://vimeo.com/97561531

Basically it was two things:

  1. Add a "debug-brk" option to grunt's mocha configuration:

    grunt.initConfig({
        ...
            "options": {
                "mocha": {
                    ...
                    "debug-brk": (grunt.option('debug-brk')) ? "" : 0
                }
            }
    }
    
  2. Configure WebStorm's Debug Configuration like this:

If you happen to use the WebStorm IDE you can set up a task and then either run or debug it.

You can see the configuration for the command grunt jasmine_node_no_coverage in the screenshot. Please note that I installed grunt globally.

Try out grunt-debug-task.

Its similar to node debugger. Just run the grunt debug taskname

I tried it out. It breaks sometimes but seems to work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!