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]: toHaveBeenCalledWith does not differentiate [undefined] and [] arguments #15446

Open
vwinkler opened this issue Jan 14, 2025 · 1 comment

Comments

@vwinkler
Copy link

Version

29.7.0

Steps to reproduce

Example steps (replace with your own):

  1. Clone my repo at https://github.com/vwinkler/jest_undefined_vs_empty_array_regression
  2. npm install
  3. npm test
  4. You should see the test results not matching my expectation

Expected behavior

× I expect this to fail
√ I expect this to pass

Actual behavior

√ I expect this to fail
× I expect this to pass

Additional context

This seems to be a regression. Jest 27 behaves as expected.

Environment

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
  Binaries:
    Node: 16.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^29.7.0 => 29.7.0
@vwinkler vwinkler changed the title [Bug]: toHaveBeenCalledWith does not differentiante [undefined] and [] arguments [Bug]: toHaveBeenCalledWith does not differentiate [undefined] and [] arguments Jan 14, 2025
@mohammednumaan
Copy link
Contributor

mohammednumaan commented Jan 15, 2025

@vwinkler Yeah. I was looking through the source and found out that the check for equality wasn't strict. It treated an empty array [] and [undefined] as equal (just like you mentioned).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants