Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update toEqual failure message #7325

Merged
merged 8 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
- `[jest-config]` Use strings instead of `RegExp` instances in normalized configuration ([#7251](https://github.com/facebook/jest/pull/7251))
- `[jest-circus]` Make sure to display real duration even if time is mocked ([#7264](https://github.com/facebook/jest/pull/7264))
- `[expect]` Improves the failing message for `toStrictEqual` matcher. ([#7224](https://github.com/facebook/jest/pull/7224))
- `[expect]` Improves the failing message for `toEqual` matcher. ([#7325](https://github.com/facebook/jest/pull/7325))
- `[jest-mock]` [**BREAKING**] Fix bugs with mock/spy result tracking of recursive functions ([#6381](https://github.com/facebook/jest/pull/6381))
- `[jest-resolve]` Fix not being able to resolve path to mapped file with custom platform ([#7312](https://github.com/facebook/jest/pull/7312))
- `[jest-message-util]` Improve parsing of error messages for unusually formatted stack traces ([#7319](https://github.com/facebook/jest/pull/7319))
Expand Down
16 changes: 2 additions & 14 deletions e2e/__tests__/__snapshots__/failures.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,8 @@ exports[`works with assertions in separate files 1`] = `

expect(received).toEqual(expected)

Expected value to equal:
2
Received:
1
Expected: 2
Received: 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This report which doesn’t display expected and received values is evidence for request to remove && !oneline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making the change you suggested did not have any effect on this snapshot. I believe that is because jest-diff returns null if the type of the expected value is number and two numbers are being compared for this test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI failed because this snapshot (which now has added lines we wanted) wasn’t updated in committed files:

Expected: 2
Received: 1

10 |
11 | module.exports = (one: any, two: any) => {
Expand All @@ -302,11 +300,6 @@ exports[`works with async failures 1`] = `

expect(received).toEqual(expected)

Expected value to equal:
{\\"baz\\": \\"bar\\"}
Received:
{\\"foo\\": \\"bar\\"}

Difference:

- Expected
Expand All @@ -331,11 +324,6 @@ exports[`works with async failures 1`] = `

expect(received).toEqual(expected)

Expected value to equal:
{\\"baz\\": \\"bar\\"}
Received:
{\\"foo\\": \\"bar\\"}

Difference:

- Expected
Expand Down
20 changes: 0 additions & 20 deletions packages/expect/src/__tests__/__snapshots__/extend.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
exports[`defines asymmetric unary matchers 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Expected value to equal:
<green>{\\"value\\": toBeDivisibleBy<2>}</>
Received:
<red>{\\"value\\": 3}</>

Difference:

<green>- Expected</>
Expand All @@ -22,11 +17,6 @@ Difference:
exports[`defines asymmetric unary matchers that can be prefixed by not 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Expected value to equal:
<green>{\\"value\\": not.toBeDivisibleBy<2>}</>
Received:
<red>{\\"value\\": 2}</>

Difference:

<green>- Expected</>
Expand All @@ -41,11 +31,6 @@ Difference:
exports[`defines asymmetric variadic matchers 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Expected value to equal:
<green>{\\"value\\": toBeWithinRange<4, 11>}</>
Received:
<red>{\\"value\\": 3}</>

Difference:

<green>- Expected</>
Expand All @@ -60,11 +45,6 @@ Difference:
exports[`defines asymmetric variadic matchers that can be prefixed by not 1`] = `
"<dim>expect(</><red>received</><dim>).toEqual(</><green>expected</><dim>)</>

Expected value to equal:
<green>{\\"value\\": not.toBeWithinRange<1, 3>}</>
Received:
<red>{\\"value\\": 2}</>

Difference:

<green>- Expected</>
Expand Down