如何调试Grunt Mocha任务? [英] How to Debug Grunt Mocha Task?
问题描述
我正在使用WebStorm运行一个咕task任务。调试器在Gruntfile.js文件的断点处成功停止,但不在我的任务文件中。
在Gruntfile.js中,我注册了一个如下所示的任务:
grunt.initConfig({
... configuration ...
});
grunt.registerTask('myTask',['mocha:myTask']);
当我在测试'myTask'的相应js文件中设置断点时,它不会停止。
如何调试grunt测试?
--- 更新 ---------------------------------------
所以我尝试了所有可能的解决方案,但它不能解决我的问题!
我能够调试grunt脚本本身,这是调试器实际上停止(在WebStorm或节点检查器中)。
问题在于,我无法调试实际的Grunt任务本身,并使用grunt注册,如下所示:
grunt.registerTask('myTask',['mocha:myTask']);
我也能够调试摩卡测试本身。但我想调试一下从grunt任务运行器调用的摩卡测试。任何想法?
最后,我可以调试我的摩卡咖啡任务!感谢您提供的所有答案和评论,但不幸的是我必须选择我自己的答案,因为这是唯一适用于我的答案。
感谢这段视频,我发现我错过了什么: http://vimeo.com/97561531
基本上有两件事:
-
为grunt的摩卡配置添加一个debug-brk选项:
grunt.initConfig({
...
选项:{
mocha:{
...
debug-brk:(grunt.option('debug-brk'))?:0
}
}
$ p
配置WebStorm的调试配置,如下所示:
I am using WebStorm to run a grunt task. The debugger successfully stops at the breakpoint in the Gruntfile.js file, but not in my task file.
In the Gruntfile.js I register a task like this:
grunt.initConfig({
... configuration ...
});
grunt.registerTask('myTask', ['mocha:myTask']);
When I set a breakpoint in the corresponding js file for the test 'myTask' it doesn't stop. How can I debug also the grunt tests?
--- UPDATE ---------------------------------------
so i tried all of your possible solutions, but it does not solve my problem!
I am able to debug the grunt script itself, this is where the debugger actually stops (either in WebStorm or node-inspector). Also a breakpoint in Gruntfile.js is working.
The problem is, that I am not able to debug the actual Grunt task itself, registered with grunt like this: grunt.registerTask('myTask', ['mocha:myTask']);
I am also able to debug the mocha test itself. But I want to debug a mocha test called from grunt task runner. Any ideas?
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:
Add a "debug-brk" option to grunt's mocha configuration:
grunt.initConfig({ ... "options": { "mocha": { ... "debug-brk": (grunt.option('debug-brk')) ? "" : 0 } } }
Configure WebStorm's Debug Configuration like this:
这篇关于如何调试Grunt Mocha任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!