-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Truncated Stack Trace #815
Comments
do you get a better .stack if you dont run with file:// ? try |
Thanks, I didn't know node had a built-in webserver, so I just learned a neat trick. However, it didn't help the stacktrace; I still get stacktraces like:
(instead of the full/real stacktrace). |
It's an old issue, but I just seen it and will answer non the less. The reason for this shortened stack is, that window.onerror only gets the message, fileUrl and lineNumber and no Error object, when catching uncaughtExceptions. Unless you use the current version of Chrome – where also column of the error and an Error object will be passed in as well – and you write something like mentioned in #958. If this still is a problem. If not, please say and tj could close this issue. :) |
Yeah, I suspected it was just an onError limitation, but I thought maybe Mocha might be able to get around that by using a (very high-level) try/catch instead of relying on onError. But if not, it can't be helped :-) |
I desperately want the inverse of this-- I ONLY want the single line that applies to the code that I've written to be returned... currently it's: Running "Mocha" task
1 -_-_,------,
1 -_-_| /\_/\
0 -_-^|__( x .x)
-_- "" ""
1 passing (15ms)
1 failing
1) mocha will fail:
Error: expected 1 to equal 0
at Assertion.assert (/Users/worker_bee/Sites/TextMateArduino/node_modules/expect.js/expect.js:99:13)
at Assertion.be.Assertion.equal (/Users/worker_bee/Sites/TextMateArduino/node_modules/expect.js/expect.js:200:10)
at Context.<anonymous> (/Users/worker_bee/Sites/TextMateArduino/public/tests/_prettyfy.js:10:25)
at Test.Runnable.run (/Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runnable.js:221:32)
at Runner.runTest (/Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:374:10)
at /Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:452:12
at next (/Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:299:14)
at /Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:309:7
at next (/Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:247:23)
at Object._onImmediate (/Users/worker_bee/Sites/TextMateArduino/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Warning: Tests failed Use --force to continue.
and what I desperately want for it to say is only: Running "Mocha" task
1 -_-_,------,
1 -_-_| /\_/\
0 -_-^|__( x .x)
-_- "" ""
1 passing (15ms)
1 failing
1) mocha will fail:
Error: expected 1 to equal 0
at Context.<anonymous> (./TextMateArduino/public/tests/_prettyfy.js:10:25)
Warning: Tests failed Use --force to continue.
All I want in this cold cruel world is a cute cat to tell me the status of my tests and- if they fail- to give me a line number and a reason/error message. There are 10 lines that I totally don't need to know about here. |
I usually get my error line on a 3rd or 4th line of the stack trace due to assertion libraries. 10 lines is a good enough choice. |
Are you @rlidwka saying that I shouldn't ask for a concise stack error option or are you agreeing with me that anything above a few lines of stack trace most of the time isn't necessary? |
@andrew-luhring look at my comments on #545 and contribute there if you think you can improve it. i think this is the job of a module, and mocha should give me everything it knows. |
@andrew-luhring I don't think filtering the stack trace is Mocha's business. However, JetBrains IDE's (and evidently Eclipse as well) have a Grep Console plugin that I use for this. I give it a regex to find |
@andrew-luhring @keyvanfatehi Shorter stack traces were added in #1564 :) |
So the only problem left here is being able to log a |
I think this is no longer an issue, @dasilvacontin. Please correct me if I'm wrong. |
I still have this problem. If I'm understanding the article linked in #958 correctly, it looks like the latest version of mocha (2.3.3) does not use the fifth argument of global.onerror = function(err, url, line, col, errobj){
fn(errobj || new Error(err + ' (' + url + ':' + line + ')'));
return !mocha.allowUncaught;
}; I get a full stack trace from Chrome, but not phantomjs. I'm not sure if it has something to do with the version of phantomjs or node I'm using? Or maybe I have something misconfigured? At any rate, here's a slightly less elegant solution that works: /**
* Report full stack trace on async callback error
*
* Wrap async callback functions with this function
* to report the full stack trace if they fail.
*
* Usage:
*
* it("will always fail", function (done) {
* someAsyncFunction(asyncatch(function (arg) {
* doSomethingThatThrowsAnError();
* done();
* }));
* });
*/
function asyncatch(fn) {
return function () {
try {
var args = Array.prototype.slice.call(arguments);
return fn.apply(this, args);
} catch (err) {
throw err && err.stack ? new Error(err.stack) : err;
}
};
} |
I've opened #2403 to address the previous comment. Maybe discussion on this should continue in issue #958 as that one is specific to async errors. |
Ah, this is #5106. |
When I run tests through the web-based runner, Mocha will take a stack trace like this:
and reduce it to:
Is this just an inherent limit of the fact that Mocha uses onerror to catch exceptions, or is there any way that Mocha could display the real stack trace instead? Because while I can get the real trace from the console, having it in the browser window would be awfully convenient.
The text was updated successfully, but these errors were encountered: