File tree 2 files changed +11
-6
lines changed
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -155,10 +155,17 @@ exports.cursor = {
155
155
}
156
156
} ;
157
157
158
- function showDiff ( err ) {
158
+ function showDiff ( err ) {
159
159
return err && err . showDiff !== false && sameType ( err . actual , err . expected ) && err . expected !== undefined ;
160
160
}
161
161
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
+
162
169
/**
163
170
* Output the given `failures` as a list.
164
171
*
@@ -204,6 +211,7 @@ exports.list = function (failures) {
204
211
}
205
212
// explicitly show diff
206
213
if ( showDiff ( err ) ) {
214
+ stringifyDiffObjs ( err ) ;
207
215
escape = false ;
208
216
fmt = color ( 'error title' , ' %s) %s:\n%s' ) + color ( 'error stack' , '\n%s\n' ) ;
209
217
var match = message . match ( / ^ ( [ ^ : ] + ) : e x p e c t e d / ) ;
@@ -290,10 +298,7 @@ function Base (runner) {
290
298
stats . failures = stats . failures || 0 ;
291
299
stats . failures ++ ;
292
300
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 ) ;
297
302
}
298
303
test . err = err ;
299
304
failures . push ( test ) ;
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ describe('List reporter', function () {
192
192
193
193
Base . cursor = cachedCursor ;
194
194
} ) ;
195
- it ( 'should immediately construct fail strings' , function ( ) {
195
+ it ( 'should immediately construct fail strings' , function ( ) {
196
196
var actual = { a : 'actual' } ;
197
197
var expected = { a : 'expected' } ;
198
198
var test = { } ;
You can’t perform that action at this time.
0 commit comments