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]: toEqual() doesn't work for iterable objects if objects have symbol property #13936

Closed
unbyte opened this issue Feb 20, 2023 · 3 comments · Fixed by #14688
Closed

[Bug]: toEqual() doesn't work for iterable objects if objects have symbol property #13936

unbyte opened this issue Feb 20, 2023 · 3 comments · Fixed by #14688

Comments

@unbyte
Copy link

unbyte commented Feb 20, 2023

Version

latest

Steps to reproduce

const Key = Symbol()
class Test {
	constructor(value) {
		this[Key] = value
	}

	[Symbol.iterator]() {
    	return [][Symbol.iterator]()
  	}
}

expect(new Test(1)).toEqual(new Test(2)) // success, because property [Key] is ignored

Expected behavior

expect(new Test(1)).toEqual(new Test(2)) // fail

Actual behavior

succeed

Additional context

Object.entries() does not return symbols, so symbols are ignored

https://github.com/facebook/jest/blob/1eb3bb5949f4ed1dbb39b9a9d9d76c3399ffd7b0/packages/expect-utils/src/utils.ts#L306-L310

Environment

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 16.17.0 - ~/.volta/tools/image/node/16.17.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 8.15.0 - ~/.volta/tools/image/node/16.17.0/bin/npm
  npmPackages:
    jest: latest => 29.4.3
@github-actions
Copy link

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.

@github-actions github-actions bot added the Stale label Mar 22, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2023
@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 May 22, 2023
@SimenB SimenB reopened this Nov 1, 2023
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.

2 participants