简体   繁体   English

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

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

How do I display a full stack trace when nodeunit catches errors? 当nodeunit捕获错误时,如何显示完整的堆栈跟踪? For example, my test is throwing: 例如,我的测试抛出:

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

How do I get nodeunit to tell me where undefined is being called as a function? 如何获取nodeunit来告诉我undefined在哪里被调用为函数?

The problem is with grunt-contrib-nodeunit: it modifies the raw nodeunit messages into something less useful. 问题出在grunt-contrib-nodeunit上:它将原始的nodeunit消息修改为不太有用的东西。 I've created an issue here . 我在这里创建了一个问题。

In short, the code that I have produced output like this with grunt-contrib-nodeunit: 简而言之,我用grunt-contrib-nodeunit产生的输出是这样的代码:

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

test.js
Fatal error: undefined is not a function

Plain nodeunit gives a more helpful error message: 普通的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()

And, as shown in the issue,when there is a stack to share grunt-contrib-nodeunit will, on occasion, hide it. 并且,如本期所示,当有一个堆栈共享grunt-contrib-nodeunit时,有时会隐藏它。

Note that the choice of reporter (grunt, default, or minimal) did not make a difference. 请注意,对报告程序的选择(响亮,默认或最小)没有任何区别。

The solution is to always run your tests with nodeunit directly whenever you get a less than helpful error message. 解决方案是,每当收到不那么有用的错误消息时,始终直接使用nodeunit运行测试。 There may be new information. 可能有新的信息。

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

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