-
-
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
[Bug]: Since Jest 29.1.0 comparing an array of complex class instances throws an error "TypeError: this is not a typed array" #14375
Comments
There is something odd inside the expect(rectangle).toMatchObject({ ...rectangle, element: expect.anything() }) If I do |
Hi @mrazauskas, Thanks for your response. The oddness occurs with any class from the library, I did the example with the rectangle just to make it short but it breaks in any place that I use Something curious is that it doesn‘t fail with What you are getting with the console.log( document.createElementNS('http://www.w3.org/2000/svg', 'path') ); // SVGElement {} Element will be always an Regards |
As you discovered that the issue is with the it('Test with toMatchObject', (): void => {
const a = document.createElementNS('http://www.w3.org/2000/svg', 'path');
expect(a).toMatchObject(a);
}); It doesn‘t fail with |
Thanks for the idea. I was able to recreate the issue in an empty repro only with /**
* @jest-environment jsdom
*/
test("document.createElementNS", () => {
const x = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
const y = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
expect(x).toMatchObject(y);
}); I was using Yarns
If I got it right, the changes I am pointing to are related (or mostly related) with the Could you confirm if adding the following to the "resolutions": {
"@jest/expect-utils": "29.3.1"
} |
The object returned by JSDOM's /**
* @jest-environment jsdom
*/
test("globalThis", () => {
expect(globalThis).toMatchObject(globalThis);
}); It passes with |
Hi @mrazauskas, |
@mrazauskas,
It could be related to that indeed, as window === window.globalThis // true
window === window.globalThis.globalThis // true |
If I got it right, @lpizzinidev @joshkel Would you have a moment to take a look? It seems that support of Symbol property keys broke Jest for users of |
Version
29.1.0
Steps to reproduce
Reproduction of the bug:
git clone git@github.com:elchininet/isometric.git
git checkout bug-jest
yarn
yarn test tests/buggy-test.test.ts
toEqual
,toStrictEqual
andtoMatchObject
)package.json
from version29.0.3
to version29.1.0
yarn
again to update the packageyarn test tests/buggy-test.test.ts
Test with toMatchObject
Expected behavior
Jest should not fail with
toMatchObject
with an array of class instances, it should pass astoEqual
ortoStrictEqual
pass.Actual behavior
Jest fails to compare an array of class instances with
toMatchObject
. It even fails with:Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: