From 30fd0b0002dea026cd165324565176db01571ab0 Mon Sep 17 00:00:00 2001 From: Alistair Brown Date: Thu, 25 Jun 2020 00:25:23 +0100 Subject: [PATCH] Update jest-diff to remove colors from no diff message Updates to the latest jest-diff which now supports removing color codes from "no visual difference" message. A test has been added to confirm this and prevent regressions in the future. Fixes #129 --- .../__snapshots__/snapshotDiff.test.js.snap | 5 ++++ __tests__/snapshotDiff.test.js | 4 +++ package.json | 2 +- yarn.lock | 30 +++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/__tests__/__snapshots__/snapshotDiff.test.js.snap b/__tests__/__snapshots__/snapshotDiff.test.js.snap index c63c20c..26e2339 100644 --- a/__tests__/__snapshots__/snapshotDiff.test.js.snap +++ b/__tests__/__snapshots__/snapshotDiff.test.js.snap @@ -166,6 +166,11 @@ exports[`failed optional deps throws with sensible message on missing react-test Cannot find module 'non-existent-module-for-testing' from '__tests__/snapshotDiff.test.js'" `; +exports[`no difference 1`] = ` +"Snapshot Diff: +Compared values have no visual difference." +`; + exports[`shows diff when comparing React fragments of varying length 1`] = ` "Snapshot Diff: - diff --git a/__tests__/snapshotDiff.test.js b/__tests__/snapshotDiff.test.js index 9e39cc9..2c9cc83 100644 --- a/__tests__/snapshotDiff.test.js +++ b/__tests__/snapshotDiff.test.js @@ -267,3 +267,7 @@ describe('failed optional deps', () => { ).toThrowErrorMatchingSnapshot(); }); }); + +test('no difference', () => { + expect(snapshotDiff('a', 'a')).toMatchSnapshot(); +}); diff --git a/package.json b/package.json index 4d02c12..dc3ab5c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "jest": ">=16" }, "dependencies": { - "jest-diff": "^26.0.1", + "jest-diff": "^26.1.0", "jest-snapshot": "^26.0.1", "pretty-format": "^26.0.1" }, diff --git a/yarn.lock b/yarn.lock index 0dec81d..846f740 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1123,6 +1123,16 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@jest/types@^26.1.0": + version "26.1.0" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.1.0.tgz#f8afaaaeeb23b5cad49dd1f7779689941dcb6057" + integrity sha512-GXigDDsp6ZlNMhXQDeuy/iYCDsRIHJabWtDzvnn36+aqFfG14JmFV0e/iXxY4SP9vbXSiPNOWdehU5MeqrYHBQ== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^1.1.1" + "@types/yargs" "^15.0.0" + chalk "^4.0.0" + "@sinonjs/commons@^1.7.0": version "1.7.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.2.tgz#505f55c74e0272b43f6c52d81946bed7058fc0e2" @@ -3628,6 +3638,16 @@ jest-diff@^26.0.1: jest-get-type "^26.0.0" pretty-format "^26.0.1" +jest-diff@^26.1.0: + version "26.1.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.1.0.tgz#00a549bdc936c9691eb4dc25d1fbd78bf456abb2" + integrity sha512-GZpIcom339y0OXznsEKjtkfKxNdg7bVbEofK8Q6MnevTIiR1jNhDWKhRX6X0SDXJlwn3dy59nZ1z55fLkAqPWg== + dependencies: + chalk "^4.0.0" + diff-sequences "^26.0.0" + jest-get-type "^26.0.0" + pretty-format "^26.1.0" + jest-docblock@^26.0.0: version "26.0.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-26.0.0.tgz#3e2fa20899fc928cb13bd0ff68bd3711a36889b5" @@ -4858,6 +4878,16 @@ pretty-format@^26.0.1: ansi-styles "^4.0.0" react-is "^16.12.0" +pretty-format@^26.1.0: + version "26.1.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.1.0.tgz#272b9cd1f1a924ab5d443dc224899d7a65cb96ec" + integrity sha512-GmeO1PEYdM+non4BKCj+XsPJjFOJIPnsLewqhDVoqY1xo0yNmDas7tC2XwpMrRAHR3MaE2hPo37deX5OisJ2Wg== + dependencies: + "@jest/types" "^26.1.0" + ansi-regex "^5.0.0" + ansi-styles "^4.0.0" + react-is "^16.12.0" + private@^0.1.6: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"