From ceffa42e22066d1bc79fd95fdf8713e066d2ebfa Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Apr 2019 00:27:39 +0200 Subject: [PATCH 1/8] Make a unified diff of sorts by abbreviating the chunks that are the same --- lib/styles.js | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/lib/styles.js b/lib/styles.js index dbe9cf519..f79dee744 100644 --- a/lib/styles.js +++ b/lib/styles.js @@ -440,7 +440,52 @@ module.exports = expect => { options.markUpSpecialCharacters ); } else { - this.stringDiffFragment(' ', value, 'text'); + const horizon = 3; + if (index === diffLines.length - 1 && part.count > horizon) { + this.stringDiffFragment( + ' ', + value + .split('\n') + .slice(0, horizon) + .join('\n'), + 'text' + ) + .nl() + .text('...'); + } else if (index === 0 && part.count > horizon) { + this.text('...') + .nl() + .stringDiffFragment( + ' ', + value + .split('\n') + .slice(0, horizon) + .join('\n'), + 'text' + ); + } else if (part.count > 2 * horizon) { + this.stringDiffFragment( + ' ', + value + .split('\n') + .slice(0, horizon) + .join('\n'), + 'text' + ) + .nl() + .text('...') + .nl() + .stringDiffFragment( + ' ', + value + .split('\n') + .slice(-horizon) + .join('\n'), + 'text' + ); + } else { + this.stringDiffFragment(' ', value, 'text'); + } } if (endsWithNewline) { this.nl(); From 0bacb589a968d5adb38fefeea690202fb4556433 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 23 Apr 2019 20:29:36 +0200 Subject: [PATCH 2/8] Show the string diff dot's with a js comment style --- lib/styles.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/styles.js b/lib/styles.js index f79dee744..6cbba40ad 100644 --- a/lib/styles.js +++ b/lib/styles.js @@ -451,9 +451,9 @@ module.exports = expect => { 'text' ) .nl() - .text('...'); + .jsComment('...'); } else if (index === 0 && part.count > horizon) { - this.text('...') + this.jsComment('...') .nl() .stringDiffFragment( ' ', @@ -473,7 +473,7 @@ module.exports = expect => { 'text' ) .nl() - .text('...') + .jsComment('...') .nl() .stringDiffFragment( ' ', From 88cfa927f6a9acdb5828516779cae143f1a5b436 Mon Sep 17 00:00:00 2001 From: Andreas Lind Date: Tue, 23 Apr 2019 20:33:05 +0200 Subject: [PATCH 3/8] Specify how many lines were omitted --- lib/styles.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/styles.js b/lib/styles.js index 6cbba40ad..55fabbc9c 100644 --- a/lib/styles.js +++ b/lib/styles.js @@ -202,6 +202,12 @@ module.exports = expect => { this.sp().block(pen); }); + expect.addStyle('diffLinesOmitted', function(lineCount) { + this.jsComment( + `... ${lineCount} line${lineCount === 1 ? '' : 's'} omitted ...` + ); + }); + expect.addStyle('removedHighlight', function(content) { this.alt({ text() { @@ -451,9 +457,9 @@ module.exports = expect => { 'text' ) .nl() - .jsComment('...'); + .diffLinesOmitted(part.count - horizon); } else if (index === 0 && part.count > horizon) { - this.jsComment('...') + this.diffLinesOmitted(part.count - horizon) .nl() .stringDiffFragment( ' ', @@ -473,7 +479,7 @@ module.exports = expect => { 'text' ) .nl() - .jsComment('...') + .diffLinesOmitted(part.count - 2 * horizon) .nl() .stringDiffFragment( ' ', From 508a77dadd9b2a0c207ca1dd9046f884063889da Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 23 Apr 2019 20:44:03 +0200 Subject: [PATCH 4/8] Fixed string diff horizon in the beginning of a diff --- lib/styles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/styles.js b/lib/styles.js index 55fabbc9c..2368c8838 100644 --- a/lib/styles.js +++ b/lib/styles.js @@ -465,7 +465,7 @@ module.exports = expect => { ' ', value .split('\n') - .slice(0, horizon) + .slice(-horizon) .join('\n'), 'text' ); From 52932d33e04a284a3c0ca5d1c723ed83f02e4dec Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 23 Apr 2019 21:08:14 +0200 Subject: [PATCH 5/8] Integration tests of the string diff truncation --- test/assertions/to-be.spec.js | 129 ++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/test/assertions/to-be.spec.js b/test/assertions/to-be.spec.js index 11a2b01b7..8f9ae12d7 100644 --- a/test/assertions/to-be.spec.js +++ b/test/assertions/to-be.spec.js @@ -78,6 +78,135 @@ describe('to be assertion', () => { ); }); + it('truncates lines in large diffs', () => { + const paragraphs = `\ + Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + short ribs, biltong boudin sausage turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + Pig ground round turducken, prosciutto pastrami ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip + steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage + boudin meatball chuck.`.replace(/^ {8}/gm, ''); + + const modifiedParagraphs = `\ + Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + shoulder buffalo boudin salami spare ribs. Bresaola picanha tri-tip, + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + short ribs, biltong boudin sausage turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + Pig ground round turducken, pastrami prosciutto ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip + steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage + boudin meatball chuck.`.replace(/^ {8}/gm, ''); + + const expectedOutput = `\ + expected 'Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky\\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\\nshoulder buffalo boudin salami spare ribs. Bresaola picanha tri-tip,\\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\\nshort ribs, biltong boudin sausage turkey.\\n\\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\\nbeef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami,\\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\\nPig ground round turducken, pastrami prosciutto ribeye pork ham hock beef\\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\\nboudin meatball chuck.' + to equal 'Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky\\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\\nshoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip,\\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\\nshort ribs, biltong boudin sausage turkey.\\n\\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\\nbeef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami,\\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\\nPig ground round turducken, prosciutto pastrami ribeye pork ham hock beef\\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\\nboudin meatball chuck.' + + Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + -shoulder buffalo boudin salami spare ribs. Bresaola picanha tri-tip, + +shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + ... 2 lines omitted ... + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + -Pig ground round turducken, pastrami prosciutto ribeye pork ham hock beef + +Pig ground round turducken, prosciutto pastrami ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip + steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage + boudin meatball chuck.`.replace(/^ {8}/gm, ''); + + expect( + () => { + expect(modifiedParagraphs, 'to equal', paragraphs); + }, + 'to throw', + expectedOutput + ); + }); + + it('truncates lines in large in the start and end', () => { + const paragraphs = `\ + Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + short ribs, biltong boudin sausage turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + Pig ground round turducken, prosciutto pastrami ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip + steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage + boudin meatball chuck.`.replace(/^ {8}/gm, ''); + + const modifiedParagraphs = `\ + Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + short ribs, biltong sausage boudin turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + Pig ground round turducken, prosciutto pastrami ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip + steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage + boudin meatball chuck.`.replace(/^ {8}/gm, ''); + + const expectedOutput = `\ + expected 'Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky\\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\\nshoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip,\\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\\nshort ribs, biltong sausage boudin turkey.\\n\\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\\nbeef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami,\\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\\nPig ground round turducken, prosciutto pastrami ribeye pork ham hock beef\\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\\nboudin meatball chuck.' + to equal 'Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky\\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\\nshoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip,\\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\\nshort ribs, biltong boudin sausage turkey.\\n\\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\\nbeef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami,\\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\\nPig ground round turducken, prosciutto pastrami ribeye pork ham hock beef\\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\\nboudin meatball chuck.' + + ... 4 lines omitted ... + strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. + Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage + bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto + -short ribs, biltong sausage boudin turkey. + +short ribs, biltong boudin sausage turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine + beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, + ... 5 lines omitted ...`.replace(/^ {8}/gm, ''); + + expect( + () => { + expect(modifiedParagraphs, 'to equal', paragraphs); + }, + 'to throw', + expectedOutput + ); + }); + it('does not provide a diff when comparing against undefined', () => { expect( function() { From 1f667888864029554e4f5c93d4c540dc0eae6695 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 23 Apr 2019 21:28:11 +0200 Subject: [PATCH 6/8] Show an example of the string truncation in the documentation --- documentation/assertions/string/to-be.md | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/documentation/assertions/string/to-be.md b/documentation/assertions/string/to-be.md index 3837cb56f..a02359b67 100644 --- a/documentation/assertions/string/to-be.md +++ b/documentation/assertions/string/to-be.md @@ -33,3 +33,67 @@ expect('Hello world!', 'not to be', 'Hello world!'); ```output expected 'Hello world!' not to be 'Hello world!' ``` + +If you compare large strings, we truncate the similar parts: + +```js +var text = `\ +Bacon ipsum amet tri-tip kielbasa kevin spare RIBS. Sirloin chuck jerky +venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket +pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami +shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, +strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. +Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage +bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto +short ribs, biltong boudin sausage turkey. + +Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine +beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, +frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. +Pig ground round turducken, pastrami prosciutto ribeye pork ham hock beef +meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip +steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage +boudin meatball chuck.`; + +var expectedText = `\ +Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky +venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket +pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami +shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, +strip steak swine short loin rump corned beef doner chuck sirloin burgdoggen. +Strip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage +bresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto +short ribs, biltong boudin sausage turkey. + +Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine +beef ribs. Prosciutto boudin pancetta ribs beef short loin porchetta pastrami, +frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. +Pig ground round turducken, pastrami prosciutto ribeye pork ham hock beef +meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip +steak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage +boudin meatball chuck.`; + +expect(text, 'to be', expectedText); +``` + + +```output +expected 'Bacon ipsum amet tri-tip kielbasa kevin spare RIBS. Sirloin chuck jerky\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\nshoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip,\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\nshort ribs, biltong boudin sausage turkey.\n\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\nbeef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami,\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\nPig ground round turducken, pastrami prosciutto ribeye pork ham hock beef\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\nboudin meatball chuck.' +to be 'Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky\nvenison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket\npastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami\nshoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip,\nstrip steak swine short loin rump corned beef doner chuck sirloin burgdoggen.\nStrip steak fatback frankfurter salami pastrami short ribs spare ribs, sausage\nbresaola porchetta turducken shoulder brisket. Tri-tip beef ribs prosciutto\nshort ribs, biltong boudin sausage turkey.\n\nPork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine\nbeef ribs. Prosciutto boudin pancetta ribs beef short loin porchetta pastrami,\nfrankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig.\nPig ground round turducken, pastrami prosciutto ribeye pork ham hock beef\nmeatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip\nsteak pastrami ham hock beef spare ribs shank kevin bacon. Pork loin sausage\nboudin meatball chuck.' + +-Bacon ipsum amet tri-tip kielbasa kevin spare RIBS. Sirloin chuck jerky ++Bacon ipsum dolor amet tri-tip kielbasa kevin spare ribs. Sirloin chuck jerky + venison leberkas. T-bone alcatra short loin short ribs spare ribs rump, brisket + pastrami frankfurter corned beef kielbasa fatback cupim andouille. Pastrami + shoulder buffalo boudin pork belly salami spare ribs. Bresaola picanha tri-tip, +... 3 lines omitted ... + short ribs, biltong boudin sausage turkey. + + Pork chop venison beef ribs leberkas pork filet mignon. Boudin leberkas swine +-beef ribs. Prosciutto boudin pancetta beef ribs short loin porchetta pastrami, ++beef ribs. Prosciutto boudin pancetta ribs beef short loin porchetta pastrami, + frankfurter corned beef. Leberkas buffalo alcatra, chuck pancetta sirloin pig. + Pig ground round turducken, pastrami prosciutto ribeye pork ham hock beef + meatloaf turkey kielbasa. Tenderloin porchetta biltong burgdoggen sirloin, strip +... 2 lines omitted ... +``` From a58edf956938e5a61065544d544b0e8ce907d358 Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Tue, 23 Apr 2019 21:52:44 +0200 Subject: [PATCH 7/8] Bump the diff limit now that we have string diff truncation --- lib/types.js | 2 +- test/types/string-type.spec.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/types.js b/lib/types.js index 9f4739388..8fd4c514f 100644 --- a/lib/types.js +++ b/lib/types.js @@ -1285,7 +1285,7 @@ module.exports = function(expect) { inspect(value, depth, output) { return output.singleQuotedString(value); }, - diffLimit: 4096, + diffLimit: 40960, diff(actual, expected, output, diff, inspect) { if (Math.max(actual.length, expected.length) > this.diffLimit) { output.jsComment(`Diff suppressed due to size > ${this.diffLimit}`); diff --git a/test/types/string-type.spec.js b/test/types/string-type.spec.js index 4331806c2..596d330d2 100644 --- a/test/types/string-type.spec.js +++ b/test/types/string-type.spec.js @@ -1,24 +1,24 @@ /* global expect */ describe('string type', () => { - it('should suppress a diff when the actual value has a length greater than 1 KB', () => { - var longString = new Array(4098).join('A'); + it('should suppress a diff when the actual value has a length greater than 40 KB', () => { + var longString = new Array(40980).join('A'); expect( function() { expect(longString, 'to equal', 'foo'); }, 'to throw', - `expected '${longString}'\nto equal 'foo'\n\nDiff suppressed due to size > 4096` + `expected '${longString}'\nto equal 'foo'\n\nDiff suppressed due to size > 40960` ); }); - it('should suppress a diff when the expected value has a length greater than 4 KB', () => { - var longString = new Array(4098).join('A'); + it('should suppress a diff when the expected value has a length greater than 40 KB', () => { + var longString = new Array(40980).join('A'); expect( function() { expect('foo', 'to equal', longString); }, 'to throw', - `expected 'foo'\nto equal '${longString}'\n\nDiff suppressed due to size > 4096` + `expected 'foo'\nto equal '${longString}'\n\nDiff suppressed due to size > 40960` ); }); }); From 48689df5a2a7a2b4f47569814dd2aa4030e1809f Mon Sep 17 00:00:00 2001 From: Sune Simonsen Date: Wed, 24 Apr 2019 20:50:36 +0200 Subject: [PATCH 8/8] Make @papandreou's OCD happy --- lib/types.js | 2 +- test/types/string-type.spec.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/types.js b/lib/types.js index 8fd4c514f..e2fa97364 100644 --- a/lib/types.js +++ b/lib/types.js @@ -1285,7 +1285,7 @@ module.exports = function(expect) { inspect(value, depth, output) { return output.singleQuotedString(value); }, - diffLimit: 40960, + diffLimit: 65536, diff(actual, expected, output, diff, inspect) { if (Math.max(actual.length, expected.length) > this.diffLimit) { output.jsComment(`Diff suppressed due to size > ${this.diffLimit}`); diff --git a/test/types/string-type.spec.js b/test/types/string-type.spec.js index 596d330d2..02c7dd09c 100644 --- a/test/types/string-type.spec.js +++ b/test/types/string-type.spec.js @@ -1,24 +1,24 @@ /* global expect */ describe('string type', () => { - it('should suppress a diff when the actual value has a length greater than 40 KB', () => { - var longString = new Array(40980).join('A'); + it('should suppress a diff when the actual value has a length greater than 64 KB', () => { + var longString = new Array(65538).join('A'); expect( function() { expect(longString, 'to equal', 'foo'); }, 'to throw', - `expected '${longString}'\nto equal 'foo'\n\nDiff suppressed due to size > 40960` + `expected '${longString}'\nto equal 'foo'\n\nDiff suppressed due to size > 65536` ); }); - it('should suppress a diff when the expected value has a length greater than 40 KB', () => { - var longString = new Array(40980).join('A'); + it('should suppress a diff when the expected value has a length greater than 64 KB', () => { + var longString = new Array(65538).join('A'); expect( function() { expect('foo', 'to equal', longString); }, 'to throw', - `expected 'foo'\nto equal '${longString}'\n\nDiff suppressed due to size > 40960` + `expected 'foo'\nto equal '${longString}'\n\nDiff suppressed due to size > 65536` ); }); });