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

Jest toEqual Matcher Doesn't Skip Undefined #64

Open
jteppinette opened this issue Jun 1, 2023 · 1 comment
Open

Jest toEqual Matcher Doesn't Skip Undefined #64

jteppinette opened this issue Jun 1, 2023 · 1 comment

Comments

@jteppinette
Copy link

jteppinette commented Jun 1, 2023

The result of myzod causes Jest's .toEqual's skipping of undefined keys to not work. I am assuming this is due to some prototype hacking?

i.e.

expect({a: undefined}).toEqual({}) // pass
expect(<same result from myzod).toEqual({}) // fail

Workaround

I am able to resolve this by recreating the object via JSON.parse/stringify:

expect(JSON.parse(JSON.stringify(result))).toEqual({}) // pass
@davidmdm
Copy link
Owner

davidmdm commented Jun 3, 2023

There is no prototype hacking in myzod. Sometimes myzod will create a new object if it's necessary, such as when coercion is used between numbers and strings and dates, or when "map" is invoked on a schema.

Perhaps this has to do with deep equality?

Myzod does not do anything esoteric to objects or their prototypes.

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

2 participants