Run node inspector with mocha

我的梦境 提交于 2019-12-20 09:55:41

问题


I can't seem to debug mocha scripts.

I am able to run node with inspector like this node --inspect script.js. This then gives me a url to go to to debug, something like chrome-devtools://devtools/remote/...

However, when I use mocha with this line mocha --inspect test.js I am not able to debug. It says 'Debugger listening on [::]:5858'. Is there any way for me to debug a mocha test using node's inspector?

Going to localhost:5858 gives me this info:

Type: connect
V8-Version: 5.1.281.84
Protocol-Version: 1
Embedding-Host: node v6.9.1
Content-Length: 0

Using --inspect --debug-brk doesn't help.


回答1:


The problem was my version of mocha. I was running a version older than 3.1.0. --inspect support was added in 3.1.0

I am now able to run with debugging with these lines:

mocha --reporter spec --inspect test.js
mocha --reporter spec --inspect-brk test.js



回答2:


[DEP0062] DeprecationWarning: node --inspect --debug-brk is deprecated. Please use node --inspect-brk instead.

use in the future

mocha --reporter spec --inspect-brk test.js


来源:https://stackoverflow.com/questions/41028932/run-node-inspector-with-mocha

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