How takefumi-yoshii/nextjs-testing-strategy-2022 works
Project type and purpose
• This is a full‑stack Next.js application showcasing a “testing strategy” for 2022. It includes:
• A React/Next.js frontend (pages, components, Storybook stories).
• Next.js API routes (serverless functions under src/pages/api).
• A Redis‑backed session store (via next-session, Docker Compose).
• A services layer for calling external APIs (services/api and services/api.example.com).
• Comprehensive testing: unit tests (Jest), integration (Jest + msw), end‑to‑end (Playwright), Storybook for components.
File structure
• Top‑level config and infra:
• docker‑compose.yaml (starts Redis).
• .env.development/production, Next.js configs (next.config.js, TypeScript).
• Jest, Playwright, Storybook configs.
• src/pages:
• _app.page.tsx, _document.page.tsx (Next.js custom wrappers).
• page routes for Posts and Users (list, detail, new, edit).
• API routes under src/pages/api (login, logout, posts, users).
• src/components:
• Follows Atomic Design (atoms → molecules → organisms → templates).
• Each component has .tsx, tests, stories, and styles.
• src/lib/next:
• Session management (next-session), API and GSSP middlewares for authentication, error handling.
• src/services:
• Client‑side fetchers and type definitions for your own API (services/api) and example external API (services/api.example.com).
• tests and e2e directories:
• Jest custom matchers, msw mocks, browser/node mocks, Playwright tests.
README
• Confirms Redis dependency and how to run the dev server: docker‑compose up (Redis) → yarn dev.
Detail
• Component hierarchy (atomic → molecules → organisms → templates) optionally as a side inset.
• Docker Compose starting Redis and the session flow.