File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,13 @@ function stringifyDiffObjs(err) {
190
190
*/
191
191
var generateDiff = ( exports . generateDiff = function ( actual , expected ) {
192
192
try {
193
+ const diffSize = 2048 ;
194
+ if ( actual . length > diffSize ) {
195
+ actual = actual . substring ( 0 , diffSize ) + ' ... Lines skipped' ;
196
+ }
197
+ if ( expected . length > diffSize ) {
198
+ expected = expected . substring ( 0 , diffSize ) + ' ... Lines skipped' ;
199
+ }
193
200
return exports . inlineDiffs
194
201
? inlineDiff ( actual , expected )
195
202
: unifiedDiff ( actual , expected ) ;
Original file line number Diff line number Diff line change @@ -164,6 +164,34 @@ describe('Base reporter', function() {
164
164
' \n actual expected\n \n a foobar inline diff\n '
165
165
) ;
166
166
} ) ;
167
+
168
+ it ( "should truncate overly long 'actual' " , function ( ) {
169
+ var actual = '' ;
170
+ var i = 0 ;
171
+ while ( i ++ < 120 ) {
172
+ actual += 'a foo unified diff ' ;
173
+ }
174
+ var expected = 'a bar unified diff' ;
175
+
176
+ inlineDiffsStub . value ( false ) ;
177
+ var output = generateDiff ( actual , expected ) ;
178
+
179
+ expect ( output , 'to match' , / \. \. \. L i n e s s k i p p e d / ) ;
180
+ } ) ;
181
+
182
+ it ( "should truncate overly long 'expected' " , function ( ) {
183
+ var actual = 'a foo unified diff' ;
184
+ var expected = '' ;
185
+ var i = 0 ;
186
+ while ( i ++ < 120 ) {
187
+ expected += 'a bar unified diff ' ;
188
+ }
189
+
190
+ inlineDiffsStub . value ( false ) ;
191
+ var output = generateDiff ( actual , expected ) ;
192
+
193
+ expect ( output , 'to match' , / \. \. \. L i n e s s k i p p e d / ) ;
194
+ } ) ;
167
195
} ) ;
168
196
169
197
describe ( 'inline strings diff' , function ( ) {
You can’t perform that action at this time.
0 commit comments