DEV Community

Kapil Gorve
Kapil Gorve

Posted on ā€¢ Originally published at jskap.com on

2 1

React Testing Library fireEvent.change example

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

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series šŸ“ŗ

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series šŸ‘€

Watch the Youtube series

šŸ‘‹ Kindness is contagious

Please leave a ā¤ļø or a friendly comment on this post if you found it helpful!

Okay