instances of different classes with same name should not be treated as equal
See original GitHub issue🐛 Bug Report
Look at example. We have two different classes but with the same name Client
.
test("", () => {
const MysqlClient = (function () {
return class Client{};
})();
const HttpClient = (function () {
return class Client{};
})();
const clients = [new MysqlClient()];
expect(clients).toEqual([new HttpClient()]); // pass
expect(clients).toStrictEqual([new HttpClient()]); // pass, but should not
});
Expected behavior
expect([new MysqlClient()]).toStrictEqual([new HttpClient()]);
should fail
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Should 2 Java objects of different classes ever be equal?
If you do not obey THAT, you are doomed to encounter problems. ... So yes, there are cases where two different classes can...
Read more >How to Implement Java's equals Method Correctly - SitePoint
Use getClass and be aware that instances of the type and its subtypes can never equal. Use instanceof but make equals final because...
Read more >Structures and Classes — The Swift Programming Language ...
An instance of a class is traditionally known as an object. However, Swift structures and classes are much closer in functionality than in...
Read more >How To Use Classes in TypeScript | DigitalOcean
This tutorial will go through the syntax used to create classes, the different features available, and how classes are treated in TypeScript ...
Read more >OBJ09-J. Compare classes and not class names
In such situations, two objects whose classes come from the same codebase could appear to the JVM to be two different classes. Also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try it and see if it break any tests 😃
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.