Skip to content
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]: Immutable.Record equality comparison failure #13051

Closed
sa2taka opened this issue Jul 21, 2022 · 1 comment · Fixed by #13055
Closed

[Bug]: Immutable.Record equality comparison failure #13051

sa2taka opened this issue Jul 21, 2022 · 1 comment · Fixed by #13055

Comments

@sa2taka
Copy link
Contributor

sa2taka commented Jul 21, 2022

Version

28.1.3

Steps to reproduce

  1. Install latest Immutable.js(v4.1.0) and jest.
    • e.g. yarn install immutable jest
  2. Create the following test file and run the test.
const Immutable = require("immutable");

it("passed in jest 27.5.1, but failure in jest 28.1.3", () => {
  class MyRecord extends Immutable.Record({ dummy: "" }) {}
  const a = new MyRecord().merge({ dummy: "data" });
  const b = new MyRecord().set("dummy", "data");
  expect(Immutable.is(a, b)).toBe(true);
  expect(a).toEqual(b);
});

Expected behavior

I expect to pass the test.

Actual behavior

The isEqual test fails.

  ● passed in jest 27.5.1, but failure in jest 28.1.3

    expect(received).toEqual(expected) // deep equality

    Expected: Immutable.Record {"dummy": "data"}
    Received: serializes to the same string

       9 |   console.log(b._values._tail.ownerID);
      10 |   expect(Immutable.is(a, b)).toBe(true);
    > 11 |   expect(a).toEqual(b);
         |             ^
      12 | });
      13 |

Additional context

This issue is similar to #12752, #12860, and #12976.
The reason to fail may be same these issues.

Immutable.Record has values of Immutable.List. The test fails because change values._tail.ownerID by the operation.

  console.log
    a._values._tail.ownerID:  OwnerID {}

      at Object.log (__tests__/index.test.js:8:11)

  console.log
    b._values._tail.ownerID:  undefined

      at Object.log (__tests__/index.test.js:9:11)

Environment

System:
  OS: macOS 12.4
  CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
Binaries:
  Node: 16.13.0 - ~/.nodenv/versions/16.13.0/bin/node
  Yarn: 1.22.17 - ~/.nodenv/versions/16.13.0/bin/yarn
  npm: 8.1.4 - ~/.nodenv/versions/16.13.0/bin/npm
npmPackages:
  jest: ^28.1.3 => 28.1.3
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant