From 977b3e171d262d42453b8d374c9659dc1c365647 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 21 Aug 2017 13:28:13 -0400 Subject: [PATCH 1/2] Join lines with newline in jest-diff --- packages/jest-diff/src/diff_strings.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/jest-diff/src/diff_strings.js b/packages/jest-diff/src/diff_strings.js index 50da0c69b30f..4a8249ffd781 100644 --- a/packages/jest-diff/src/diff_strings.js +++ b/packages/jest-diff/src/diff_strings.js @@ -71,11 +71,11 @@ const diffLines = (a: string, b: string): Diff => { .map(line => { const highlightedLine = highlightTrailingWhitespace(line, bgColor); const mark = color(part.added ? '+' : part.removed ? '-' : ' '); - return mark + ' ' + color(highlightedLine) + '\n'; + return mark + ' ' + color(highlightedLine); }) - .join(''); + .join('\n'); }) - .join('') + .join('\n') .trim(), isDifferent, }; @@ -125,16 +125,16 @@ const structuredPatch = (a: string, b: string, contextLines?: number): Diff => { const bgColor = getBgColor(added, removed); const highlightedLine = highlightTrailingWhitespace(line, bgColor); - return color(highlightedLine) + '\n'; + return color(highlightedLine); }) - .join(''); + .join('\n'); isDifferent = true; return shouldShowPatchMarks(hunk, oldLinesCount) ? createPatchMark(hunk) + lines : lines; }) - .join('') + .join('\n') .trim(), isDifferent, }; From da541de14080b95cc814a1969f4a3f0cd3939409 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Wed, 23 Aug 2017 10:27:23 -0400 Subject: [PATCH 2/2] Delete trim method and update snapshot (works with node assert) --- .../__tests__/__snapshots__/failures.test.js.snap | 6 +++--- packages/jest-diff/src/diff_strings.js | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/integration_tests/__tests__/__snapshots__/failures.test.js.snap b/integration_tests/__tests__/__snapshots__/failures.test.js.snap index 98e588e7107f..bf9554f627e8 100644 --- a/integration_tests/__tests__/__snapshots__/failures.test.js.snap +++ b/integration_tests/__tests__/__snapshots__/failures.test.js.snap @@ -150,7 +150,7 @@ exports[`works with node assert 1`] = ` - Expected + Received - Object { + Object { \\"a\\": Object { \\"b\\": Object { - \\"c\\": 6, @@ -178,7 +178,7 @@ exports[`works with node assert 1`] = ` - Expected + Received - Object { + Object { \\"a\\": Object { \\"b\\": Object { - \\"c\\": 7, @@ -247,7 +247,7 @@ exports[`works with node assert 1`] = ` - Expected + Received - Object { + Object { - \\"a\\": 2, + \\"a\\": 1, } diff --git a/packages/jest-diff/src/diff_strings.js b/packages/jest-diff/src/diff_strings.js index 4a8249ffd781..56fbe03e3d52 100644 --- a/packages/jest-diff/src/diff_strings.js +++ b/packages/jest-diff/src/diff_strings.js @@ -75,8 +75,7 @@ const diffLines = (a: string, b: string): Diff => { }) .join('\n'); }) - .join('\n') - .trim(), + .join('\n'), isDifferent, }; }; @@ -134,8 +133,7 @@ const structuredPatch = (a: string, b: string, contextLines?: number): Diff => { ? createPatchMark(hunk) + lines : lines; }) - .join('\n') - .trim(), + .join('\n'), isDifferent, }; };