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

Improve toWarnDev matcher DX for unexpected warnings #12082

Merged

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Jan 23, 2018

Use jest-diff to format the warnings in a way that makes it easier to spot the differences.

Before

The differences before are hard to spot!
screen shot 2018-01-23 at 11 19 45 am

After

One unmatched expectation

If there's a single unmatched expectation, then just diff the individual strings:
screen shot 2018-01-23 at 11 15 00 am

Multiple unmatched expectations

Wrap in an array and do a diff. Let Jest decide which of the inner strings is closest. In some cases the diff might not be useful (if the warning was a completely different one than you were expecting) but in other cases the output can be meaningful:
screen shot 2018-01-23 at 11 14 34 am

No remaining expected warnings

Just print the unexpected warning by itself:
screen shot 2018-01-23 at 11 14 51 am

Use jest-diff to format the warnings in a way that makes it easier to spot the differences.
@bvaughn bvaughn force-pushed the improve-unexpected-warning-diff-for-toWarnDev branch from 903a4c8 to 45e82b0 Compare January 23, 2018 19:30
@bvaughn bvaughn merged commit d0e75dc into facebook:master Jan 23, 2018
@bvaughn bvaughn deleted the improve-unexpected-warning-diff-for-toWarnDev branch January 23, 2018 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants