I have a function like this:
const doThingWithTarget = (event, someBoolean) => {
if(someBoolean) otherFunction(event.currentTarget); // uses currentTarget
}
// more code ...
return (<Button onClick={event => doThingEithEvent(event, true)}>Click me!</Button>)
And I am having to test this button was called clicked, and I wanted to make sure the first argument has a currentTarget:
expect(doThingWithTarget).toHaveBeenCalledWith(
expect.objectContaining({ currentTarget: expect.any(Function) }), true,
);
But react is detecting me accessing the currentTarget on the synthetic element and throwing an error.
How can I avoid that? It shouldn't be erroring.