question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Sep 19, 2018

Try it and see if it break any tests 😃

0reactions
github-actions[bot]commented, May 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found