What’s the correct call to fire an
onChange
event on an input with react-testing-library’sfireEvent
API?fireEvent.change(input, { target: { value: 'myValue' } });
fireEvent.change(input, { value: 'myValue' });
fireEvent.onChange(input, { target: { value: 'myValue' } });
How would you fire a click event on a submit button with react-testing-library
fireEvent
API?fireEvent.onClick(button);
fireEvent.click(button);
fireEvent.onClick(button, { target: { value: 'submit' } });
When locating an element by using one of the screen querying methods from react-testing-library, such as
screen.getByRole
orscreen.getByLabelText
, what would be the return value of the call if the element is not found?An error will be thrown
null
undefined