react-testing-library - appending characters to an input or text area

Viewed 1048

I have a use case where I need to type a few characters into a text area, test something, and then append more characters into that text area. How do I do this? If I call fireEvent.change() twice in succession, the second call overwrites the content, instead of appending to it.

fireEvent.change(getByTestId('text-txt-area'), {
    target: { value: '123' }
});

// Overwrites '123' instead of appending '456'
fireEvent.change(getByTestId('text-txt-area'), {
    target: { value: '456' }
});
0 Answers
Related