【发布时间】:2015-07-10 04:19:53
【问题描述】:
node.js 中有没有办法(最好也是 mocha)来模拟 python 的行为
python -m pdb setup.py test
如果程序抛出未捕获的异常,这将回退到调试接口。
编辑
@robertklep 建议使用未记录的breakOnException 命令,该命令看起来非常棒,但在实践中并没有那么多:
test.js
var hello = {};
function testFunc () {
anotherFunct();
}
function anotherFunct () {
var b = hello.unfound;
}
testFunc();
然后它冻结在:
$ node debug test.js
< Debugger listening on port 5858
connecting to port 5858... ok
break in test.js:1
> 1 var hello = {};
2 function testFunc () {
3 anotherFunct();
debug> breakOnException
debug> c
debug> backtrace
EDIT2:test.js 首先没有产生错误。以上工作正常。
【问题讨论】:
-
您可能应该使用像
node-inspector这样的“适当的”远程调试器,REPL 客户端相当有限。 FWIW,您展示的示例没有任何问题,因此代码运行并完成。也许这就是回溯导致它冻结的原因(这显然仍然很糟糕)。 -
你说得对,我很粗心。谢谢。
标签: javascript node.js debugging mocha.js