Expect toMatchObject
diff to match object type
#6580
Labels
p3-minor-bug
An edge case that only affects very specific usage (priority)
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: