In jest, how do I use “toHaveBeenCalledWith” and only match part of an object in an array argument?
You can use a combination of arrayContaining and objectContaining to make this work. Reference: https://jestjs.io/docs/expect#expectarraycontainingarray https://jestjs.io/docs/expect#expectobjectcontainingobject Here is some sample code for you: function something(a, b, somefn) { somefn([{ x: a, y: b, id: ‘some-guid’ }]); } test(‘Testing something’, () => { const mockSomeFn = jest.fn(); something(2, 3, mockSomeFn); expect(mockSomeFn).toHaveBeenCalledWith( expect.arrayContaining([ expect.objectContaining({ x: 2, y: … Read more