问题
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