jest: [Bug]: toHaveBeenCalledWith matching issue in jest@^30.0.0-alpha.7
Version
30.0.0-alpha.5
Steps to reproduce
- Clone https://github.com/mnahkies/jest-30-toHaveBeenCalledWith-regression
- Run
yarn - Run
yarn test/jest index.spec.js
Expected behavior
I expect all tests to pass.
Actual behavior
The test matches the second call with toHaveBeenCalledWith fails when using 30.0.0-alpha.5 / 30.0.0-alpha.4.
With earlier versions of jest all tests pass, so I believe this is a regression in the latest v30 alpha versions.
Additional context
I’ve included some other tests in that file to show that the matching still behaves as expected if you:
- Re-order the calls to the spy
- Only call the spy once
- Use
toHaveBeenNthCalledWithinstead oftoHaveBeenCalledWith
It seems likely that there is some issue with short-circuiting the matching falsely/too early. I can’t immediately spot where this is happening though.
Environment
System:
OS: macOS 13.5.2
CPU: (12) arm64 Apple M2 Pro
Binaries:
Node: 20.3.1 - ~/.asdf/installs/nodejs/20.3.1/bin/node
Yarn: 1.22.19 - ~/.asdf/installs/nodejs/20.3.1/bin/yarn
npm: 9.6.7 - ~/.asdf/plugins/nodejs/shims/npm
npmPackages:
jest: 30.0.0-alpha.5 => 30.0.0-alpha.5
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 20 (2 by maintainers)
Still an issue in 30.0.0-alpha.7 https://github.com/mnahkies/jest-30-toHaveBeenCalledWith-regression/commit/0d541b5a2b1e06e9b8fb60bc0beaa686a9a67b35