Skip to content

Conversation

@azatoth
Copy link
Contributor

@azatoth azatoth commented Mar 20, 2011

looked into the stack trace issue, and what I think is that only filename and line number of entry two in the general stack trace are relevant to show

I've come to the understanding that mot of the stack trace are
irrelevant, thus this commit will remove all of it except the file and
line number of the second entry in the stack trace which empirically
matches the probable invocation in the test code
@caolan
Copy link
Owner

caolan commented Mar 21, 2011

Sounds interesting, I'll take a look when I get chance. I'm a little worried about removing useful stacktrace info from test failures though.

@azatoth
Copy link
Contributor Author

azatoth commented Mar 21, 2011

I've been trying to think about the issue a lot, and following is my understanding of how it works, please correct me if I'm wrong:

  • when test.ok() etc. is called, the stack trace up to this point only contains nodeunit invocations, none of which are relevant to find the error in question.
  • the arguments to the test functions have returned when the test function are executed, thus any intresting stack trace are lost.
  • the test function makes one extra call before it ends up at the AssertError handler (I'm not certain if this always is the truth, but it seems so)

I've not tested with exception assertions, though I don't think they will be included in the stack trace, as it would imply that the stack trace are merged at some point (which doesn't make any sense).

@mgutz
Copy link

mgutz commented Aug 20, 2011

I have a slightly different approach in my self-contained branch. The inline reporter removes any lines that have 'nodeunit/' in them and also colorizes any line that belongs to the module being tested. Definitely much better signal-to-noise ratio.

@mreinstein
Copy link
Collaborator

Instead of removing stack traces entirely can we have an option to explicitly hide them? I'm doing test driven development, and so I have a gigantic suite of tests that fail. as I implement the code more tests start to pass, but its almost unusable iteratively because the stack traces dont mean anything and take up a huge amount of space in the output. The default option would of course be to NOT hide them, I'd be super happy with the option to enable this behavior, especially at the beginning of my projects where my tests are a big mountain of fail. :)

@statico
Copy link

statico commented Dec 2, 2012

+1 @mreinstein — An option to hide stack traces would be fantastic.

(nodeunit rocks, keep up the good work!)

@Sneppers
Copy link

@caolan (or anyone) is this possible now?
Seeing the entire stack trace on each test failure must be the most annoying thing about using Nodeunit. If I want to see the trace I should be able to enable it, no?

Assertion Message: No data available for this user.
AssertionError: 404 == 200
    at Object.equal (/opt/local/lib/node_modules/nodeunit/lib/types.js:83:39)
    at Request._callback (/Users/XXX/XXX/Development/XXX/API-Testing/test.js:208:10)
    at Request.self.callback (/Users/XXX/XXX/Development/XXX/API-Testing/node_modules/request/request.js:122:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/XXX/XXX/Development/XXX/API-Testing/node_modules/request/request.js:888:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/XXX/XXX/Development/XXX/API-Testing/node_modules/request/request.js:839:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

In my case the first two lines are more than enough.
Please let me know.

@Sneppers
Copy link

So, basically what @mreinstein said.
+1 to that.

@caolan
Copy link
Owner

caolan commented Mar 28, 2014

+1 to what @mreinstein said, an option to turn off stack traces would be nice

@leachryanb
Copy link

+1 to option @mreinstein

iahs added a commit to iahs/nodeunit that referenced this pull request Aug 8, 2014
Fixes error when stack trace is hidden with ```Error.stackTraceLimit = 0```
Potentially provides a fix to caolan#64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants