使用Mocha调试NodeJs程序时出错 [英] Error while debugging NodeJs program using mocha

查看:157
本文介绍了使用Mocha调试NodeJs程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一些测试用例,并且正在尝试使用mocha和node debug调试测试用例.

I have written some test cases and I am trying to debug the test cases using using mocha and node debug.

我的机器上已安装摩卡

我安装了节点调试npm install -g node-debug

然后我通过以下命令进行测试:node-debug _mocha test.js

Then I am running test by this command: node-debug _mocha test.js

这将打开浏览器窗口,但出现以下错误

This opens a browser window, but I am getting following error

Detached from the target

Remote debugging has been terminated with reason: Error: connect ECONNREFUSED. Is node running with --debug port 5858?
Please re-attach to the new target.

有关更多信息,请参见所附图片:

See the attached image for more information:

如何摆脱这个错误.请帮忙.

How can I get rid of this error. Please help.

推荐答案

已弃用node-debug项目.

如果使用节点> 6.3,则调试器是节点核心的一部分!

If using node > 6.3, The debugger is a part of the node core!

请参见 https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.3qx9qfmwl

如果使用节点< 6.3,您可以使用node-inspector

If using node < 6.3, you can use node-inspector

查看 https://github.com/node-inspector/node-inspector

如果在完成调试之前测试未结束过程,则其余部分应该会顺利进行.您还可以设置--debug-brk,使其在代码的第一行停止,以使慢速人员有机会进入调试器.

The rest should be smooth sailing if your test is not ending the process before you're done debugging. You can also set --debug-brk so it stops on the first line of your code to give us slow humans a chance to get to the debuggeer.

祝你好运!

这篇关于使用Mocha调试NodeJs程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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