What I would like to do
I would like to pass some custom properties to an event during some tests (using react-testing-library and jest). I am using the fireEvent function. I understand from the docs that the properties in the second argument are added to the event. This is what I can't do at the moment.
Minimal reproducible example
import React from 'react'
import { render, fireEvent } from '@testing-library/react'
test('check event', () => {
const DOM = render(
<div
onClick={event => {
console.log(event.foo)
}}
>
Click Me
</div>
)
// here I am expecting foo to be a property on the event passed
// to the event handler. But that doesn't happen.
fireEvent.click(DOM.getByText('Click Me'), { foo: 'bar' })
})
The result is that undefined is logged.
Approaches I've tried / thoughts
I have tried various variations of this using different event types, using createEvent, using custom events, manually adding an event listener etc. and I can't seem to access any of the event properties I pass in with any of these variations.
I've looked under the cover a bit at what's going on in fireEvent here. It certainly looks like those additional properties should be added.