-
-
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]: Jest reports different URL objects as PASS. #14399
Comments
Hm.. Are you sure? The following fails as expected: /**
* @jest-environment node
*/
test("url test", () => {
expect(new URL("https://jestjs.io/")).toEqual(
new URL("https://jestjs.io/docs/getting-started"),
);
}); But this will pass (and that is wrong): /**
* @jest-environment jsdom
*/
test("url test", () => {
expect(new URL("https://jestjs.io/")).toEqual(
new URL("https://jestjs.io/docs/getting-started"),
);
}); |
By the way, if you are happy about the solution in the fix you suggested, why not to compare only /**
* @jest-environment jsdom
*/
test("url test", () => {
expect(new URL("https://jestjs.io/").href).toEqual(
new URL("https://jestjs.io/docs/getting-started").href,
);
}); The thing is that what you suggest is a breaking change. Users might be interested to compare the whole object and that should be possible. For example, if |
Just tried it, it results PASS for me in node.js
That's the workaround im doing for now, but still its a bug if it reports PASS when its actually not. |
Does not reproduce for me. Could you create a reproduction repo so I could see the whole setup? Or just wait and perhaps someone else will figure out what is going on. |
It really depends on the node version, for me on node 20 it always passes and on node 14 the tests fail because the url/hrefs don't match. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
I ran into this on Node 20 with the |
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. |
Version
29.6.2-dev
Steps to reproduce
Expected behavior
I expect this test to FAIL.
Actual behavior
Jest reports this test as PASS.
Additional context
I have fixed this bug in this pr(#14398) which happens primarily in Node.js environment.
Environment
System: OS: Linux 6.4 CachyOS Linux CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H Binaries: Node: 20.5.0 - /usr/bin/node Yarn: 1.22.19 - /usr/bin/yarn npm: 9.8.1 - /usr/bin/npm npmPackages: jest: ^29.6.2 => 29.6.2
The text was updated successfully, but these errors were encountered: