使用Mocha运行节点检查器 [英] Run node inspector with mocha

查看:84
本文介绍了使用Mocha运行节点检查器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法调试摩卡脚本.

I can't seem to debug mocha scripts.

我能够像这样的node --inspect script.js用检查器运行节点.然后,这给了我一个URL进行调试,例如chrome-devtools://devtools/remote/...

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/...

但是,当我在此行mocha --inspect test.js中使用mocha时,我无法调试.它说调试器正在侦听[::]:5858".我有什么办法可以使用节点的检查器调试Mocha测试吗?

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?

去localhost:5858会给我这个信息:

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

使用--inspect --debug-brk没有帮助.

推荐答案

问题是我的摩卡版本.我运行的版本早于3.1.0.在 3.1.0中添加了--inspect支持.

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

这篇关于使用Mocha运行节点检查器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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