使用mocha的--debug-brk开关启用节点调试器的正确方法是什么? [英] What's the right way to enable the node debugger with mocha's --debug-brk switch?

查看:128
本文介绍了使用mocha的--debug-brk开关启用节点调试器的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的测试模块中有一些调试器语句,想要运行mocha并设置--debug-brk并点击我的断点,以便我可以检查模块的状态。不幸的是,每当我用这个选项运行mocha时,我最后会在下一行显示一个空白光标。我可以输入文本,但似乎没有任何东西可以处理我的命令(它当然看起来不像节点调试器):

I have some debugger statements in my module under test and want to run mocha with --debug-brk set and hit my breakpoint so that I can inspect the state of my module. Unfortunately, whenever I run mocha with this option, I end up with a blank cursor on the next line. I can enter text, but there's nothing that appears to be processing my commands (it certainly doesn't look like the node debugger):

$ mocha --debug-brk tests.js -R spec
debugger listening on port 5858
[BLANK CURSOR]

我是否在推出摩卡咖啡时出错?

Am I doing something wrong with how I'm launching mocha?

推荐答案

回答原始问题,即使我还建议您查看 node-inspector :您可以使用通过mocha内置到节点中的CLI调试器和 debug 选项,而不是 - debug - debug-brk 标志。 (注意缺少破折号。)

To answer the original question, even though I also suggest you look into node-inspector: you can use the CLI debugger built into node through mocha with the debug option, instead of the --debug or --debug-brk flags. (Notice the lack of dashes.)

在你的例子中,它将是:

In your example, instead, it would be:

$ mocha debug tests.js -R spec
debugger listening on port 5858
connecting... ok
break in node_modules/mocha/bin/_mocha:7
  5  */
  6 
  7 var program = require('commander')
  8   , sprintf = require('util').format
  9   , path = require('path')
debug> [CURSOR]

再次, debug as上面用粗体表示,没有破折号。 (=

Again, debug as above in bold, with no dashes. (=

相关: https://github.com/visionmedia / mocha / issues / 247

这篇关于使用mocha的--debug-brk开关启用节点调试器的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆