You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I checked out this package and added the following to the toHaveBeenCalledOnceWith.test.js file
test('passes if comparing two empty `Map`s',()=>{mock(newMap());expect(mock).toHaveBeenCalledOnceWith(newMap());});test('passes if comparing two non-empty `Map`s',()=>{consttestMap=newMap([['key1','value1'],['key2','value2'],]);mock(testMap);expect(mock).toHaveBeenCalledOnceWith(testMap);});test('fails if comparing two `Map`s with different entries',()=>{consttestMap1=newMap([['key1','value1'],['key2','value2'],]);consttestMap2=newMap([['key3','value3'],['key4','value4'],]);mock(testMap1);expect(()=>expect(mock).toHaveBeenCalledOnceWith(testMap2)).toThrowErrorMatchingSnapshot();});
test('toHaveBeenCalledOnceWith with Maps',()=>{consttestMap1=newMap([['key1','value1'],['key2','value2'],]);consttestMap2=newMap([['key3','value3'],['key4','value4'],]);constmyMock=jest.fn();myMock(testMap1);expect(myMock).toHaveBeenCalledOnceWith(testMap1);// This passess as expectedexpect(myMock).toHaveBeenCalledOnceWith(testMap2);// This passes, but it should failexpect(myMock).toHaveBeenCalledWith(testMap2);// This fails as jest's native `toHaveBeenCalledWith` implementation detects the mismatch});
What happened (please provide anything you think will help):
The toHaveBeenCalledWith matcher cannot detect Maps with differently entries while jest's native toHaveBeenCalledWith does.
Reproduction repository (if possible):
N/A
The text was updated successfully, but these errors were encountered:
The equals function is defined in Jest itself here. Jest's toHaveBeenCalledWithalso uses this function. I'm trying to understand why there seems to be a difference in behavior.
Bug
package
version:3.2.4
node
version:16.10.0
npm
(oryarn
) version:yarn 1.22.19
Relevant code or config
Most likely this line making the comparison:
jest-extended/src/matchers/toHaveBeenCalledOnceWith.js
Line 20 in 4617269
What you did:
toHaveBeenCalledOnceWith.test.js
fileWhat happened (please provide anything you think will help):
The
toHaveBeenCalledWith
matcher cannot detectMap
s with differently entries while jest's nativetoHaveBeenCalledWith
does.Reproduction repository (if possible):
N/A
The text was updated successfully, but these errors were encountered: