How do I display a full stack trace when nodeunit catches errors? 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?
The problem is with grunt-contrib-nodeunit: it modifies the raw nodeunit messages into something less useful. I've created an issue here.
In short, the code that I have produced output like this with 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:
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.
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. There may be new information.