This directory contains comprehensive React Testing Library tests for the CV application components, organized in a clean folder structure.
testing-library/
├── components/ # Individual component tests
│ ├── Hero.test.tsx
│ ├── Personal.test.tsx
│ ├── Experience.test.tsx
│ ├── Education.test.tsx
│ ├── Skills.test.tsx
│ ├── Resume.test.tsx
│ ├── Menu.test.tsx
│ └── LangSwitcher.test.tsx
├── integration/ # Integration tests
│ └── Integration.test.tsx
├── utils/ # Test utilities
│ └── Components.tsx
└── README.md # This file
Hero.test.tsx- Tests for the Hero component (personal information display)Personal.test.tsx- Tests for the Personal/About sectionExperience.test.tsx- Tests for the Experience sectionEducation.test.tsx- Tests for the Education sectionSkills.test.tsx- Tests for the Skills sectionResume.test.tsx- Tests for the Resume/PDF viewMenu.test.tsx- Tests for the navigation menuLangSwitcher.test.tsx- Tests for the language switcher
Integration.test.tsx- End-to-end integration tests covering navigation, language switching, and cross-component interactions
Components.tsx- Shared test utilities includingrenderMockRootfunction for rendering components with routing and i18n context
- Using
getByRole,getByText,getByLabelTextinstead of CSS selectors - Prioritizing user-facing queries over implementation details
- Testing for proper ARIA roles and attributes
- Ensuring keyboard navigation works correctly
- Verifying screen reader compatibility
- Testing what users see and interact with
- Focusing on behavior rather than implementation
- Testing user workflows and navigation
- Testing component rendering
- Testing user interactions (clicks, form inputs)
- Testing navigation and routing
- Testing internationalization
- Testing responsive design classes
- Descriptive test names
- Proper setup and teardown
- Isolated test cases
- Clear assertions
# Run all tests
npm test
# Run tests in watch mode
npm test -- --watch
# Run specific test file
npm test components/Hero.test.tsx
# Run all component tests
npm test -- --run src/client/tests/testing-library/components/
# Run integration tests
npm test -- --run src/client/tests/testing-library/integration/
# Run tests with coverage
npm test -- --coverageit('renders personal information correctly', () => {
renderMockRoot({ initialEntries: ['/cv/en/'] });
expect(screen.getByText('Hanna')).toBeInTheDocument();
expect(screen.getByText('Gaudasińska-Zapaśnik')).toBeInTheDocument();
expect(screen.getByText('JavaScript Developer')).toBeInTheDocument();
});it('switches language when clicking on alternative language', () => {
renderMockRoot({ initialEntries: ['/cv/en/'] });
const langButton = screen.getByText('EN');
fireEvent.click(langButton);
const plOption = screen.getByText('PL');
fireEvent.click(plOption);
expect(screen.getByText('PL')).toBeInTheDocument();
});it('navigates between different sections', () => {
renderMockRoot({ initialEntries: ['/cv/en/'] });
const skillsLink = screen.getByRole('link', { name: /wrench/i });
fireEvent.click(skillsLink);
expect(screen.getByText('Skills')).toBeInTheDocument();
});- ✅ Component rendering and content display
- ✅ Navigation between sections
- ✅ Language switching (EN/PL)
- ✅ Contact links and external URLs
- ✅ Technology icons with tooltips
- ✅ Responsive design classes
- ✅ Accessibility attributes
- ✅ User interactions and events
- ✅ Integration between components
- ✅ Routing and URL handling
- Tests use
renderMockRootutility to provide proper context (routing, i18n, styles) - All tests are written with user experience in mind
- Tests focus on behavior rather than implementation details
- Comprehensive coverage of all major user workflows
- Tests are maintainable and easy to understand