Is there a method similar to objectContaining that uses toBe instead of toEqual property checks?
The following contrived test case (which passes) highlights the issue. I would like to assert that the event.target object is actually button1 and should therefore fail for the similar object button2.
test('foo', () => {
const button1 = document.createElement('button');
const button2 = document.createElement('button');
const onClick = jest.fn();
button1.addEventListener('click', onClick);
button1.click();
expect(onClick).toBeCalledWith(expect.objectContaining({type: 'click', target: button2}));
});
Alternatively, how could I rewrite this test case to support my required assertions?
Aucun commentaire:
Enregistrer un commentaire