أسئلة المجتمع — تصفّح أو اطرح سؤالك.
لا توجد أسئلة منشورة بعد.
رسائل بريد عند نشر مقالات جديدة.
Automated Testing with Jest and React Testing Library
Buckky Moral
نُشر:
لم يُترجم هذا المقال بعد. يُعرض بلغته الأصلية.

الملخص
Write comprehensive tests for your React applications.
Testing Strategy
Good tests give confidence in your code.
Unit Tests
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Button from './Button';
test('button click calls handler', async () => {
const handleClick = jest.fn();
render(Click me);
await userEvent.click(screen.getByText('Click me'));
expect(handleClick).toHaveBeenCalledTimes(1);
});
التعليقات
جارٍ تحميل التعليقات…