-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Feature]: jest-diff
should allow configuring sorting of object keys
#11938
Comments
PR welcome! |
Hi, From what I see the sorting is happening here -> https://github.com/facebook/jest/blob/main/packages/pretty-format/src/collections.ts#L12. |
I believe we've always sorted there. The reason is I assume because it's easier to read objects that are sorted alphabetically, so it seems natural something which prints a "pretty" version of an object would do so |
That makes sense @SimenB. I'm not aware of the other uses of So the approach for implementing this feature would be to add an option in |
Yeah, that seems like a reasonable approach! PR very much welcome 🙂 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Allow configuring the object key sorting for
jest-diff
. At present it sorts alphabetically. It should allow using the existing sorting, or providing a function to sort before visual diff is generated.Motivation
I am trying to diff two
package.json
files, and it keys are being sorted alphabetically when displaying the diff. This makes it hard to eyeball, because keys are not where you think they will be.Example
No response
Pitch
There is no way around it with the way
jest-diff
is designed.The text was updated successfully, but these errors were encountered: