Skip to content

Commit 760b4db

Browse files
committed
re-add stringify during list to appease tests, open for discussion if this is correct behavior
1 parent 09226eb commit 760b4db

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/reporters/base.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,17 @@ exports.cursor = {
155155
}
156156
};
157157

158-
function showDiff(err) {
158+
function showDiff (err) {
159159
return err && err.showDiff !== false && sameType(err.actual, err.expected) && err.expected !== undefined;
160160
}
161161

162+
function stringifyDiffObjs (err) {
163+
if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
164+
err.actual = utils.stringify(err.actual);
165+
err.expected = utils.stringify(err.expected);
166+
}
167+
}
168+
162169
/**
163170
* Output the given `failures` as a list.
164171
*
@@ -204,6 +211,7 @@ exports.list = function (failures) {
204211
}
205212
// explicitly show diff
206213
if (showDiff(err)) {
214+
stringifyDiffObjs(err);
207215
escape = false;
208216
fmt = color('error title', ' %s) %s:\n%s') + color('error stack', '\n%s\n');
209217
var match = message.match(/^([^:]+): expected/);
@@ -290,10 +298,7 @@ function Base (runner) {
290298
stats.failures = stats.failures || 0;
291299
stats.failures++;
292300
if (showDiff(err)) {
293-
if (!utils.isString(err.actual) || !utils.isString(err.expected)) {
294-
err.actual = utils.stringify(err.actual);
295-
err.expected = utils.stringify(err.expected);
296-
}
301+
stringifyDiffObjs(err);
297302
}
298303
test.err = err;
299304
failures.push(test);

test/reporters/list.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ describe('List reporter', function () {
192192

193193
Base.cursor = cachedCursor;
194194
});
195-
it('should immediately construct fail strings', function() {
195+
it('should immediately construct fail strings', function () {
196196
var actual = { a: 'actual' };
197197
var expected = { a: 'expected' };
198198
var test = {};

0 commit comments

Comments
 (0)