jest-react-testing
Audited by Runlayer on Feb 21, 2026
Malicious tool definition detected
Tool: EXAMPLES.md [1/7] Description: # Jest React Testing Examples Comprehensive collection of real-world testing examples covering common scenarios and patterns in React application testing.
Tool: EXAMPLES.md [2/7] Description: { return res(ctx.status(500)); }) ); render(<UserProfile userId="1" />); const errorMessage = await screen.findByRole('alert'); expect(errorMessage).toHaveTextContent(/failed to fetch user/i); }); it('refetches when userId changes', async () => { const { rerender } = render(<UserProfile userId="1" />); await screen.findByRole('heading', { name: /john doe/i }); // Update server to return different user server.use( rest.get('/api/users/:userId', (req, res, ctx)
Tool: EXAMPLES.md [3/7] Description: => setIsOpen(!isOpen)} aria-haspopup="listbox" aria-expanded={isOpen} aria-labelledby="dropdown-label" > {selectedOption ?
Tool: EXAMPLES.md [4/7] Description: await user.type(input, 'Buy groceries'); await user.click(addButton); expect(screen.getByText(/buy groceries/i)).toBeInTheDocument(); }); it('toggles todo completion', async () => { const user = userEvent.setup(); const initialState = { todos: { items: [{ id: 1, text: 'Test todo', completed: false }], }, }; renderWithStore(<TodoList />, { store: createMockStore(initialState) }); const checkbox = screen.getByRole('checkbox', { name: /toggle test todo/i }); con
Tool: EXAMPLES.md [5/7] Description: => ( <li key={option} role="option" aria-selected={index === highlightedIndex} onClick={() => handleSelect(option)} style={{ backgroundColor: index === highlightedIndex ?
Tool: EXAMPLES.md [6/7] Description: ```javascript // AccessibleForm.test.jsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { AccessibleForm } from './AccessibleForm'; describe('AccessibleForm - Accessibility', () => { it('has accessible form structure', () => { render(<AccessibleForm onSubmit={jest.fn()} />); const form = screen.getByRole('form'); expect(form).toHaveAccessibleName('User Information'); }); it('has accessible
Tool: EXAMPLES.md [7/7] Description: 100)}% </div> <CurrentStepComponent onNext={handleNext} onBack={handleBack} initialData={formData} isFirstStep={currentStep === 0} isLastStep={currentStep === steps.length - 1} /> </div> ); }; ``` ### Tests ```javascript // FormWizard.test.jsx import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { FormWizard } from './FormWizard'; // Mock step components const Step1 = ({ onNext, isFirstStep }) =>
Malicious tool definition detected
Tool: README.md [1/2] Description: # Jest React Testing > Comprehensive testing guide for React applications using Jest and React Testing Library ## Overview This skill provides a complete guide to testing React applications using Jest and React Testing Library.
Tool: README.md [2/2] Description: up after tests - Test error states ### Don'ts - Don't test implementation details - Don't use getByTestId unless necessary - Don't over-mock - Don't test internal state - Don't use fireEvent when userEvent works - Don't skip accessibility - Don't chase 100% coverage - Don't write brittle tests ## Debugging ### View DOM Structure ```javascript import { screen } from '@testing-library/react'; screen.debug(); // Prints entire DOM screen.debug(element); // Prints s
Malicious tool definition detected
Tool: SKILL.md [1/4] Description: --- name: jest-react-testing description: Comprehensive React component testing with Jest and React Testing Library covering configuration, mocking strategies, async testing patterns, hooks testing, and integration testing best practices --- # Jest React Testing A comprehensive skill for testing React applications using Jest and React Testing Library.
Tool: SKILL.md [2/4]
Tool: SKILL.md [3/4] Description: jest.useRealTimers(); }); it('updates timer every second', () => { render(<Timer />); expect(screen.getByText(/0 seconds/i)).toBeInTheDocument(); act(() => { jest.advanceTimersByTime(1000); }); expect(screen.getByText(/1 second/i)).toBeInTheDocument(); act(() => { jest.advanceTimersByTime(3000); }); expect(screen.getByText(/4 seconds/i)).toBeInTheDocument(); }); it('cleans up timer on unmount', () => { const { unmount } = render(<Timer />); const clearIntervalSp
Tool: SKILL.md [4/4] Description: 3.