diff --git a/CHANGELOG.md b/CHANGELOG.md index 39dfdbd77b9a..2a75e1c80fc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - `[jest-jasmine2]` Use prettier through `require` instead of `localRequire`. Fixes `matchInlineSnapshot` where prettier dependencies like `path` and `fs` are mocked with `jest.mock`. ([#6776](https://github.com/facebook/jest/pull/6776)) - `[docs]` Fix contributors link ([#6711](https://github.com/facebook/jest/pull/6711)) - `[website]` Fix website versions page to link to correct language ([#6734](https://github.com/facebook/jest/pull/6734)) +- `[expect]` Update `toContain` suggestion to contain equal message ([#6792](https://github.com/facebook/jest/pull/6810)) ## 23.4.1 diff --git a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap index 6667bd36aac4..ea01adb411dc 100644 --- a/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap +++ b/packages/expect/src/__tests__/__snapshots__/matchers.test.js.snap @@ -1517,7 +1517,9 @@ exports[`.toContain(), .toContainEqual() '[{}, []]' does not contain '[]' 1`] = Expected array: [{}, []] To contain value: - [] Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher. You probably need to use \`toContainEqual\` instead." + [] + +Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher. You probably need to use \`toContainEqual\` instead." `; exports[`.toContain(), .toContainEqual() '[{}, []]' does not contain '{}' 1`] = ` @@ -1526,7 +1528,9 @@ exports[`.toContain(), .toContainEqual() '[{}, []]' does not contain '{}' 1`] = Expected array: [{}, []] To contain value: - {} Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher. You probably need to use \`toContainEqual\` instead." + {} + +Looks like you wanted to test for object/array equality with the stricter \`toContain\` matcher. You probably need to use \`toContainEqual\` instead." `; exports[`.toContain(), .toContainEqual() '[0, 1]' contains '1' 1`] = ` diff --git a/packages/expect/src/matchers.js b/packages/expect/src/matchers.js index 1edd47ec2e2a..848e8f1de30f 100644 --- a/packages/expect/src/matchers.js +++ b/packages/expect/src/matchers.js @@ -313,7 +313,7 @@ const matchers: MatchersObject = { ` ${printReceived(collection)}\n` + `To contain value:\n` + ` ${printExpected(value)}` + - (suggestToContainEqual ? ` ${SUGGEST_TO_CONTAIN_EQUAL}` : '') + (suggestToContainEqual ? `\n\n${SUGGEST_TO_CONTAIN_EQUAL}` : '') ); };