-
-
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
showDiff: don’t stringify strings + tests #1477
Conversation
I've seen PRs for this already, although they didn't have tests (and that was probably the reason they aren't merged already). I'll take a look at the PR later today. |
|
||
// actual / expected diff | ||
if (err.showDiff && 'string' == typeof actual && 'string' == typeof expected) { | ||
if ('string' !== typeof actual) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marcello3d Why was err.showDiff
removed from the conditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, err.showDiff was being checked twice before, and only once now. It's easier to see in the side-by-side diff.
good, thx |
showDiff: don’t stringify strings + tests
@boneskull Maybe it would be a good idea to bump, since this bug was causing problems to a few people. |
@dasilvacontin Yeah I want to bump soon, no time right now though. |
@boneskull, sure. I could take care of it, if you are interested. |
Thanks y'all. :-) Getting back into mocha (hadn't tried it since 1.13.0), lots of nice touches. |
The showDiff feature is stringifying strings as JSON, which flattens multi-line text with \n and surrounds them with quotes.
I refactored the code slightly to only call
utils.stringify
if the actual/expected values are not strings.You can see the bug by running mocha on the following .js file:
Current (mocha 2.0.1) output:
After patch: