Sobes.tech
Middle

Have you had experience writing tests?

sobes.tech AI

Answer from AI

Yes, I have experience writing tests in frontend development. I usually use Jest for unit testing React components and business logic. For testing the user interface, I use React Testing Library, which allows simulating user interactions and checking component behavior.

Here's a simple React test example using Jest and React Testing Library:

import { render, screen, fireEvent } from '@testing-library/react';
import Button from './Button';

test('button calls handler on click', () => {
  const onClick = jest.fn();
  render(<Button onClick={onClick}>Click me</Button>);

  fireEvent.click(screen.getByText('Click me'));
  expect(onClick).toHaveBeenCalledTimes(1);
});

This approach helps ensure the stability and correctness of components when code changes.

Have you had experience writing tests? — Frontend - sobes.tech