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: Add preventEqualsOnEntities method for Jest. #971

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stephenh
Copy link
Collaborator

Using toEquals with entities can cause issues b/c:

  • The equality does a deep comparison of the entities & ends up diffing the entire EntityManager/ConnectionPool
  • If equality fails, the toEquals diff similarily prints the entire entity + EntityManager + ConnectionPool

While it's possible to add custom equality matchers, to recognize the entities and do a custom equals check, it's not possible to, if the entities are not equal, provide a custom diff output.

Because of this, we've created our own toMatchEntity, but it's hard to remember to use it, so this prompts the prompt by just breaking toEquals on entities all together.

Using toEquals with entities can cause issues b/c:

* The equality does a deep comparison of the entities & ends up diffing
  the entire EntityManager/ConnectionPool
* If equality fails, the toEquals diff similarily prints the entire
  entity + EntityManager + ConnectionPool

While it's possible to add custom equality matchers, to recognize the
entities and do a custom equals check, it's not possible to, if the
entities are _not_ equal, provide a custom diff output.

Because of this, we've created our own toMatchEntity, but it's hard
to remember to use it, so this prompts the prompt by just breaking
toEquals on entities all together.
@stephenh stephenh force-pushed the add-prevent-equals-on-entities branch from 6a939d0 to 1872475 Compare May 17, 2024 04:09
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

1 participant