-
Notifications
You must be signed in to change notification settings - Fork 163
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
So, duplicate error messages #60
Comments
@wizardwerdna hi! I think it because jasmine@2.x change error message format: You can try fix it here Thanks! |
Yep, that's the ticket. Of course, I could parse the message, eliminate "Error:" and return from inside there, but I think the fix should happen somewhere deeper in the jasmine.js file, when a stack is being returned, but shouldn't be, or something like that. I'm loathe to take the easy solution if something simpler is available. In the Jasmine 1.0 code, the failed message returns with no stack trace, so the if(stack) is not executed. I just can't grok what's going on inside. Anybody more clueful than I? |
Well, its trickier. First of all, thew new karma-jasmine relies on jasmine-core code, rather than a local jasmine.js. Sound, but its hard to imagine how to easily make this change. Assuming that all we need to do is to suppress the stack whenever its first line, without the "Error: " is identical to the message, then the following code works: function firstLineOfStackWithoutLeadingErrorDifferentFromMessage(){
var firstLine = stack.substring(0, stack.indexOf('\n') - 1);
return message && message.indexOf(firstLine.replace(/^Error: */, '')) === -1;
};
if (stack && firstLineOfStackWithoutLeadingErrorDifferentFromMessage()) { and of course this can be refactored to get rid of the duplication of code within the if. Does that seem to be how we should attack this problem? If so, I can submit a pull request. |
There hasn't been much interest in solutions to this problem, although it renders karma-jasmine unworkable for me. Accordingly, since I don't require any Jasmine 2.0 features for my work, I'll just continue to use the 1.5 version of karma-jasmine for now. |
Do we really want to remove the stack trace? I think it's quite useful. I would be interested, however, in the removal of all karma- and jasmine-related fluff from the stack. |
@olegskl no. Issue about remove 'duplicated' lines: Expected '' to be '2'.
Error: Expected '' to be '2'. |
Oh, okay. I was thinking that it would be good to have something like: PhantomJS 1.9.8 (Mac OS X) ngFromHtml() should work for simple dynamic html FAILED
Expected '' to be '2'.
at /Users/werdna/wiz-dev-env/test/environment.js:33 instead of: PhantomJS 1.9.8 (Mac OS X) ngFromHtml() should work for simple dynamic html FAILED
Expected '' to be '2'.
Error: Expected '' to be '2'.
at /Users/werdna/wiz-dev-env/test/environment.js:33
at /Users/werdna/wiz-dev-env/node_modules/karma-jasmine/lib/boot.js:126
at /Users/werdna/wiz-dev-env/node_modules/karma-jasmine/lib/adapter.js:171
at http://localhost:9876/karma.js:189
at http://localhost:9876/context.html:49 What do you think? |
The long stack trace is of at most modest interest to me, during TDD what I want to know is what errors occurred with a useful error message. I like to use a split window with a relatively small window for the test output. Frankly, the trace information for EVERY expectation renders karma pretty useless to me, particularly as the test scrolls to the bottom of the flow, so I have to scroll up for EVERY red message. This works best for me with my TDD workflow, whether under vi or WebStorm. I continue to use the 1.X karma because I can't get any value out of the status quo. Of course, when there is no jasmine error message because of a catastrophic crash, a full trace is helpful -- that is what happened in the pre 2.X karma-jasmine. |
fixed in ee4a020 |
Hi there, was looking at that thread, is there a good reason to return step.stack rather than step.message? In my case I get a long useless requirejs stack trace following the error message, and I'm guessing the same issue could always occur with other libs used. I suggest that if the irrelevant stack trace is removed anyway why not always return step.message instead of adding new regex tests such as !//(require.js):/.test(entry) |
@bstenm The stack is pretty useful. It would be great though to have a configuration option that would filter out library/framework stack traces. |
agreed that would be the best solution, also with a 'no-stack-trace' one would be good in which case it just returns step.message |
👍 for configuration option on stack traces. |
This is not fixed yet, at least not correctly. For example, my context contains expect(window.MyGlobalVariable)
.withContext('Was not in global var: ' + JSON.stringify(window.jQuery, null, 2))
.toEqual(jasmine.objectContaining({
'my/tested/key': jasmine.objectContaining({
default: jasmine.anything()
})
}));
|
The drivers (and this may be a driver issue) working with Jasmine 1.X would result in concise assertion failure reports along the lines of:
However, under Jasmine 2.x, we get duplicated errors messages:
The latter yields overlong messages and lots of undesireable cruft.
Whaddya think? I'm happy to research this, but perhaps there is a simple and obvious solution my colleagues may provide?
The text was updated successfully, but these errors were encountered: