-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Expect toMatchObject
diff to match object type
#6580
Comments
So, this could be the expected behavior than showing
|
Looking it again, it's probably desirable to preserve prototypes inside diff, which is currently dropped "Received" side. This is due to a recent change to slim down the diff for I checked Jest and they also got the same bug as this code is mostly based on them. Here is a repro in Jest https://stackblitz.com/edit/github-caqski?file=basic.test.js |
Describe the bug
When I use
expect(testObject).toMatchObject(expectedObject)
I expect the diff to report the correct type forReceived
as it does forExpected
.For example, say I have the two classes
Foo
andBar
:Then I expect the following test:
To report the types as it does in the
AssertionError
Yet it shows expecting a
Foo
and receiving anObject
, while I would expectObject
to beBar
here.Now there have been cases (when this problem occurs in a nested object) where I had to add additional logging on failure to determine that
Object
is in factBar
to pinpoint the cause of the error, which would have been unnecessary if the diff reported the correct type.Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-qmrkzs?file=test%2Fbasic.test.ts
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: