Error while debugging NodeJs program using mocha

為{幸葍}努か 提交于 2019-12-23 03:04:33

问题


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

I have mocha installed on my machine

I installed node-debug npm install -g node-debug

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.


回答1:


That is expected behavior once your tests have finished running. Put a long timeout in your test so it does not die and try it again.

You will also want to run mocha with a very high timeout so your tests don't die timing out.




回答2:


The node-debug project is deprecated.

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

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

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

Check out https://github.com/node-inspector/node-inspector

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.

Best of luck!



来源:https://stackoverflow.com/questions/22681767/error-while-debugging-nodejs-program-using-mocha

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