| name | tdd-frontend |
| description | Write a new React component or page using TDD with Jest and React Testing Library for PlaylistMiner Next.js frontend. |
TDD Feature Implementation (Next.js)
Implement the requested component or page using TDD.
Step 1: Write Jest Test
- Create test file alongside the component:
ComponentName.test.tsx
- Use React Testing Library:
render, screen, userEvent
- Test rendering, user interactions, edge cases
- Run
npm test — confirm tests FAIL
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { ComponentName } from './ComponentName';
describe('ComponentName', () => {
it('renders the expected content', () => {
render(<ComponentName />);
expect(screen.getByText('Expected')).toBeInTheDocument();
});
});
Step 2: Implement Component
- Write minimal component to pass tests
- TypeScript strict — no
any types
- Use TanStack Query for API calls via custom hooks
- Tailwind CSS only — no custom CSS
- Run
npm test — confirm tests PASS
Step 3: Write E2E Test (if page-level)
- Add Playwright test in
e2e/ for the user flow
- Test the happy path end-to-end
- Run
npm run test:e2e — confirm it passes
Rules
- Server components by default,
"use client" only when needed
- API calls go through hooks in
hooks/, never directly in components
- All hooks use the auto-generated API client
- Check dark mode and responsive layout