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

fix(expect): align toEqual to jest #4246

Merged
merged 9 commits into from
Jan 29, 2024

Conversation

eryue0220
Copy link
Contributor

This pr is to solve #4244

@eryue0220 eryue0220 requested a review from kt3k as a code owner January 28, 2024 06:06
@eryue0220 eryue0220 changed the title fix: align to jest expect fix(assert): align to jest expect Jan 28, 2024
@kt3k
Copy link
Member

kt3k commented Jan 28, 2024

Thanks for trying this, but this is significant breaking change to assertEquals and we can't merge this.

Fundamental issue here is that we share the same logic for assertEquals and expect().toEqual() but they have many incompatibilities in edge cases.

I think it's time to fork assertEquals for std/expect to safely diverge these 2 different APIs. Can you copy the necessary part of assertEquals under expect/ as internal utilities and apply these change to them?

@eryue0220
Copy link
Contributor Author

Thanks for trying this, but this is significant breaking change to assertEquals and we can't merge this.

Fundamental issue here is that we share the same logic for assertEquals and expect().toEqual() but they have many incompatibilities in edge cases.

I think it's time to fork assertEquals for std/expect to safely diverge these 2 different APIs. Can you copy the necessary part of assertEquals under expect/ as internal utilities and apply these change to them?

Sure, I'll update this.

@eryue0220 eryue0220 marked this pull request as draft January 29, 2024 02:00
@eryue0220
Copy link
Contributor Author

eryue0220 commented Jan 29, 2024

I‘ve update the std/expect, which will refers to toEqual and toStrictEqual. Besides fix the issues #4244 cases, this pr also aligns some other cases to jest.

@eryue0220 eryue0220 marked this pull request as ready for review January 29, 2024 04:52
@kt3k
Copy link
Member

kt3k commented Jan 29, 2024

Looks great! Thanks for these changes.

I'd like to point one another thing. The below doesn't pass in Jest, but it passes with this change.

class A {}
class B {}
expect(new A()).toStrictEqual(new B());

I think we need to add constructor check if strictCheck is true.

@eryue0220
Copy link
Contributor Author

Looks great! Thanks for these changes.

I'd like to point one another thing. The below doesn't pass in Jest, but it passes with this change.

class A {}
class B {}
expect(new A()).toStrictEqual(new B());

I think we need to add constructor() check if strictCheck is true.

Thank you,

I've fixed this problem.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM. This looks great improvements towards jest compatibility. Thanks for working on this!

@kt3k kt3k changed the title fix(assert): align to jest expect fix(expect): align to jest expect Jan 29, 2024
@kt3k kt3k changed the title fix(expect): align to jest expect fix(expect): align toEqual to jest Jan 29, 2024
@kt3k kt3k merged commit 67fe57c into denoland:main Jan 29, 2024
12 checks passed
@eryue0220 eryue0220 deleted the fix/expect-align-to-jest branch January 29, 2024 09:17
kt3k pushed a commit to kt3k/deno_std that referenced this pull request Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants