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

feat(rules): add prefer-strict-equal #134

Merged
merged 3 commits into from Aug 11, 2018

Conversation

tryggvigy
Copy link
Contributor

This PR will

Implement the prefer-strict-equal rule. This rule serves to encourage stricter equality checks on objects.

Why?

The believe is that imposing stricter equality results in safer tests.

@tryggvigy
Copy link
Contributor Author

tryggvigy commented Jul 29, 2018

The desire to make strict equality the default behaviour has been discussed. This rule at least makes it enforceable. Maybe this should be a part of the recommended rules?

# Suggest using `toStrictEqual()` (prefer-strict-equal)

`toStrictEqual` not only checks that two objects contain the same data but also
that they have the same shape. The believe is that imposing a stricter equality
Copy link
Member

Choose a reason for hiding this comment

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

"The believe is that" sounds odd. Could you re-phrase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tweaked and expanded on this a bit in a7ca3b2

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks for sending a PR! Left some comments in the docs, code LGTM


This rule triggers a warning if `toEqual()` is used to assert equality.

This rule is enabled by default.
Copy link
Member

Choose a reason for hiding this comment

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

no it's not 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, addressed in a7ca3b2

Also remove mention of the rule being enabled by default. It's not
@SimenB SimenB merged commit 92b1d5c into jest-community:master Aug 11, 2018
@SimenB
Copy link
Member

SimenB commented Aug 11, 2018

Thanks!

@SimenB
Copy link
Member

SimenB commented Aug 11, 2018

🎉 This PR is included in version 21.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants