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

Utility to prevent using toEqual on entities #969

Open
stephenh opened this issue Mar 11, 2024 · 0 comments
Open

Utility to prevent using toEqual on entities #969

stephenh opened this issue Mar 11, 2024 · 0 comments

Comments

@stephenh
Copy link
Collaborator

When Jest diffs entities for like expect(result).toEqual(someEntity), it deep crawls into each entity and ends up diffing the entire EntityManager / connection pool / etc.

Besides just being slow, if the assertions ever fail, the diff output is huge.

We've added toMatchEntity to work around the inability to custom toEquals diff output, but it's easy to forget to use it.

We could probably add a custom equality matcher, see here:

https://github.com/jestjs/jest/blob/9113f44b459f96db31e5ad3811d4d8b07f79e54f/packages/expect-utils/src/jasmineUtils.ts#L79

That doesn't actually provide custom equality, but instead just tells the user to use toMatchEntity instead.

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

No branches or pull requests

1 participant