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]: toThrow and toStrictEqual matchers compare only message field of errors #13604

Closed
tbossi opened this issue Nov 11, 2022 · 4 comments
Closed

Comments

@tbossi
Copy link
Contributor

tbossi commented Nov 11, 2022

Version

29.3.1

Steps to reproduce

  1. Clone my repo https://github.com/tbossi/jest-bug-error-match
  2. Run npm test
  3. The tests fail

Expected behavior

All tests should pass.

Specifically:

  1. Custom error objects with same message field value but different other fields values should not be equal.
  2. In JavaScript you can throw custom objects (not extending Error), therefore the toThrow matcher should compare the whole object and not only the message field (which could be missing).

Actual behavior

Error objects equality is only established by comparing the message field.

Additional context

No response

Environment

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
Binaries:
    Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
npmPackages:
    jest: ^29.3.1 => 29.3.1
@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 Dec 11, 2022
@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 Jan 10, 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
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 Feb 10, 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.

1 participant