React Testing Library fireEvent.change example

April 09, 2020

Example -

import React from 'react';
import { cleanup, render, fireEvent } from '@testing-library/react';

import App from './App';


it('Enter principal amount', async () => {
  const { getByTestId } = render(<App />);
  const principalInputElement = getByTestId('principalInput') as HTMLInputElement;
  fireEvent.change(principalInputElement, {target: {value: '20000'}});

Connect With Me!!

Get updates about React, React Native, NodeJs, Web Development, Freelancing and Business. No Spam.

+91 9922234778

Kapil Gorve LinkedIn ProfileKapil Gorve Twitter AccountKapil Gorve Quora ProfileKapil Gorve Github Account