This demo project includes unit tests for key parts of the app using Jest and React Testing Library:
- Button Test → Verifies the button renders correctly, responds to clicks, and respects the disabled state.
- UserCard Test → Mocks API calls to ensure the component displays user data correctly and handles API errors safely.
- useCounter Hook Test → Confirms the custom hook increases, decreases, and resets values as expected.
- formatCurrency Utility Test → Checks that currency values are formatted properly for different locales (e.g., US dollars vs. German euros).
-
npm run dev
Starts the Next.js development server with Turbopack for fast HMR (Hot Module Reloading). Visit the app at http://localhost:3000 -
npm run test
Runs Jest test suite once. Includes all unit tests for components, hooks, and utilities. -
npm run test:watch
Runs Jest in watch mode → automatically re-runs tests when files change. Ideal for local development. -
npm run test:ci
Runs Jest in CI mode with coverage reports (--coverage).