diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c60e81dd02b..6d3305ac0c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ### Fixes +- `[jest-diff]` Do not claim that `-0` and `0` have no visual difference ([#7605](https://github.com/facebook/jest/pull/7605)) - `[jest-mock]` Fix automock for numeric function names ([#7653](https://github.com/facebook/jest/pull/7653)) - `[jest-config]` Ensure `existsSync` is only called with a string parameter ([#7607](https://github.com/facebook/jest/pull/7607)) - `[expect]` `toStrictEqual` considers sparseness of arrays. ([#7591](https://github.com/facebook/jest/pull/7591)) diff --git a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap index f8e39e5fc99a..1debb403a675 100644 --- a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap +++ b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap @@ -360,11 +360,7 @@ exports[`.toBe() fails for: -0 and 0 1`] = ` "expect(received).toBe(expected) // Object.is equality Expected: 0 -Received: -0 - -Difference: - -Compared values have no visual difference." +Received: -0" `; exports[`.toBe() fails for: 1 and 2 1`] = ` diff --git a/packages/jest-diff/src/index.js b/packages/jest-diff/src/index.js index 716e863fb1c4..32b62ae4b9dc 100644 --- a/packages/jest-diff/src/index.js +++ b/packages/jest-diff/src/index.js @@ -46,7 +46,7 @@ const FALLBACK_FORMAT_OPTIONS_0 = {...FALLBACK_FORMAT_OPTIONS, indent: 0}; // Generate a string that will highlight the difference between two values // with green and red. (similar to how github does code diffing) function diff(a: any, b: any, options: ?DiffOptions): ?string { - if (a === b) { + if (Object.is(a, b)) { return NO_DIFF_MESSAGE; }