Example -
import React from 'react';
import { cleanup, render, fireEvent } from '@testing-library/react';
import App from './App';
afterEach(cleanup);
it('Enter principal amount', async () => {
const { getByTestId } = render(<App />);
const principalInputElement = getByTestId('principalInput') as HTMLInputElement;
fireEvent.change(principalInputElement, {target: {value: '20000'}});
expect(getByTestId('emititle')).toHaveTextContent('1758');
});
This post was originally published at https://www.jskap.com/notes/react-testing-library-fireevent-change/
👋 Hi! I’m Kapil. I am always chatty about building things, sharing my learnings, freelancing. Come say hi to me at https://twitter.com/kapilgorve
Top comments (0)