-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Reusing property matchers causes incorrect matching failure #9089
Labels
Comments
Thanks for the report, confirmed! Based on your `seenReferences remarks probably introduced by #8687 |
i am working on this |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
🐛 Bug Report
Reusing the same objects with property matchers results in unsuccessful validation of the object towards it.
To Reproduce
Steps to reproduce the behavior:
{ createdAt: expect.any(String) }
{ foo: timestampMatcher, bar: timestampMatcher }
{ foo: { createdAt: "def" }, bar: { createdAt: "def", baz: "ab1" } }
expect(value).toMatchSnapshot(B);
Expected behavior
I expected to successfully create snapshots, because value satisfy the property matcher constrains.
Instead I get the follwing error.
Debug info
Creating new matcher A for each property of B (
{ foo: {...timestampMatcher}, bar: {...timestampMatcher} }
) does not trigger the error and works as expected. (shown in MWE)I tried to debug it and found out that it is caused by
seenReferences
"caching" inexpect
. Disabling this if block fixes the issue.Alas I could not find a way to fix it without disabling the seenRefences feature.
Link to repl or repo (highly encouraged)
https://github.com/grissius/jest-bug-reuse-property-matchers
envinfo
The text was updated successfully, but these errors were encountered: