-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
area: usabilityconcerning user experience or interfaceconcerning user experience or interfacesemver-majorimplementation requires increase of "major" version number; "breaking changes"implementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!
Description
Right now the unified diff output has no separators. Resulting in output similar to this:
Having not used mocha in some time, I had completely forgotten it splits before/after 4 lines from the affected text and spent a while trying to figure out how "PD" could possibly be having values of "15/30" or "50/100".
I don't know what kind of separator to add, but a blank line or two should suffice for majority of cases. I'd have to check to see if other libraries have tackled this problem how they went about it.
The code to modify would be this:
Lines 161 to 207 in 7493bca
| failures.forEach(function(test, i){ | |
| // format | |
| var fmt = color('error title', ' %s) %s:\n') | |
| + color('error message', ' %s') | |
| + color('error stack', '\n%s\n'); | |
| // msg | |
| var err = test.err | |
| , message = err.message || '' | |
| , stack = err.stack || message | |
| , index = stack.indexOf(message) | |
| , actual = err.actual | |
| , expected = err.expected | |
| , escape = true; | |
| if (index === -1) { | |
| msg = message; | |
| } else { | |
| index += message.length; | |
| msg = stack.slice(0, index); | |
| // remove msg from stack | |
| stack = stack.slice(index + 1); | |
| } | |
| // uncaught | |
| if (err.uncaught) { | |
| msg = 'Uncaught ' + msg; | |
| } | |
| // explicitly show diff | |
| if (err.showDiff !== false && sameType(actual, expected) | |
| && expected !== undefined) { | |
| escape = false; | |
| if (!(utils.isString(actual) && utils.isString(expected))) { | |
| err.actual = actual = utils.stringify(actual); | |
| err.expected = expected = utils.stringify(expected); | |
| } | |
| fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n'); | |
| var match = message.match(/^([^:]+): expected/); | |
| msg = '\n ' + color('error message', match ? match[1] : msg); | |
| if (exports.inlineDiffs) { | |
| msg += inlineDiff(err, escape); | |
| } else { | |
| msg += unifiedDiff(err, escape); | |
| } | |
| } |
mceachen
Metadata
Metadata
Assignees
Labels
area: usabilityconcerning user experience or interfaceconcerning user experience or interfacesemver-majorimplementation requires increase of "major" version number; "breaking changes"implementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!Mocha can use your help with this one!
