I am still learning react testing library. I understand you can use
fireEvent to trigger an event on an element and the function signature of
fireEvent[eventName](node: HTMLElement, eventProperties: Object)
If I want to dispatch a click event, essentially I have to do something like the following.
getByText is one of the built-in selectors.
- Can I also do something like
fireEvent.click(document.getElementById('btn'));. Is it considered anti-pattern to do that? I have noticed it works but I have not yet seen it used in a codebase.
- Is it possible to access the
eventparameter in the event handler?