繁体   English   中英

如何在Nodeunit中显示完整的堆栈跟踪?

[英]How do I display full stack trace in Nodeunit?

当nodeunit捕获错误时,如何显示完整的堆栈跟踪? 例如,我的测试抛出:

✔ event delete - basic
✔ delete - errors
Fatal error: undefined is not a function

如何获取nodeunit来告诉我undefined在哪里被调用为函数?

问题出在grunt-contrib-nodeunit上:它将原始的nodeunit消息修改为不太有用的东西。 我在这里创建了一个问题。

简而言之,我用grunt-contrib-nodeunit产生的输出是这样的代码:

user@desktop:~/bug_test$ grunt
Running "nodeunit:all" (nodeunit) task

test.js
Fatal error: undefined is not a function

普通的nodeunit给出了更有用的错误消息:

user@desktop:~/bug_test$ nodeunit test.js 

test.js

FAILURES: Undone tests (or their setups/teardowns): 
- testSomethingElse

To fix this, make sure all tests call test.done()

并且,如本期所示,当有一个堆栈共享grunt-contrib-nodeunit时,有时会隐藏它。

请注意,对报告程序的选择(响亮,默认或最小)没有任何区别。

解决方案是,每当收到不那么有用的错误消息时,始终直接使用nodeunit运行测试。 可能有新的信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM