Skip to content

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?

@tryggvigy tryggvigy force-pushed the prefer-strict-equal branch from 1bfcd98 to d7c2c33 Compare July 29, 2018 23:37
# 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.

2 participants