CoachnestCoachnest
Sign InGet Started
Back to course

Next.js 16: The Complete Developer Guide

…
—
Contents
1

What's New in Next.js 16

Reading14mFree
2

Installation, CLI & Your First Project

Reading12mFree
3

Project Structure & Conventions Deep Dive

Reading16m
4

Turbopack — The New Default Bundler

Video18m
5

Configuring TypeScript, ESLint & next.config.ts

Reading14m
6

Chapter 1 — Quiz

Quiz10m
7

App Router Fundamentals

Reading16m
8

Dynamic Routes, Catch-Alls & Type-Safe Params

Reading14m
9

Route Groups & Parallel Routes

Reading16m
10

Intercepting Routes & Modal Patterns

Reading12m
11

Loading, Error & Not-Found UI

Reading12m
12

Chapter 2 — Routing Quiz

Quiz12m
13

Understanding the Server/Client Boundary

Reading18m
14

Choosing When to use "use client"

Reading14m
15

Composing Server & Client Components

Reading14m
16

server-only, client-only & Code Splitting

Reading12m
17

Chapter 3 — Quiz

Quiz10m
18

Fetching Data in Server Components

Reading14m
19

The Next.js 16 Cache Model

Reading16m
20

Revalidation: revalidateTag, revalidatePath & On-Demand

Reading12m
21

Cache Components — Building Reusable Cached Functions

Reading14m
22

Search Params, Cookies & Dynamic APIs

Reading12m
23

Chapter 4 — Quiz

Quiz12m
24

Server Actions From First Principles

Reading16m
25

Forms with useActionState & Progressive Enhancement

Reading14m
26

Optimistic UI with useOptimistic

Reading12m
27

Validation with Zod + Server Actions

Reading12m
28

Chapter 5 — Quiz

Quiz10m
29

Static vs Dynamic vs Streaming

Reading14m
30

generateStaticParams & Pre-Rendering Dynamic Routes

Reading12m
31

Incremental Static Regeneration (ISR)

Reading12m
32

Partial Prerendering (PPR)

Reading16m
33

Edge Runtime vs Node.js Runtime

Reading12m
34

Rendering Strategies Deep Dive

Video22m
35

Chapter 6 — Quiz

Quiz12m
36

Tailwind CSS v4 with Next.js 16

Reading14m
37

CSS Modules, Global Styles & Scoped CSS

Reading10m
38

next/image — Smart, Fast Images

Reading14m
39

Fonts, Icons & Metadata

Reading12m
40

Chapter 7 — Quiz

Quiz10m
41

Middleware Fundamentals

Reading14m
42

Sessions, JWTs & Cookies

Reading16m
43

Protecting Server Components & Server Actions

Reading12m
44

Chapter 8 — Quiz

Quiz10m
45

Prisma with Next.js — The Production Setup

Reading14m
46

Mutations: Server Actions + Database Writes

Reading12m
47

Route Handlers & REST APIs

Reading12m
48

Chapter 9 — Quiz

Quiz10m
49

Unit & Component Testing with Vitest

Reading12m

End-to-End Testing with Playwright

Reading14m
51

Deploying to Vercel

Reading12m
52

Self-Hosting with Docker

Reading14m
53

Production Performance Checklist

Reading12m
54

Final Assessment — Next.js 16 Mastery

Quiz20m
←→navigate lessons
Chapter 10 of 10·Chapter 10 — Testing, Deployment & Production
Lesson 50 of 54Reading14 min

End-to-End Testing with Playwright

#End-to-End Testing with Playwright¶

E2E tests open a real browser, navigate, click buttons, and verify the rendered output. Use them for critical user journeys — signup, checkout, the main feature loop.

Install¶

bash
1 line
1npm init playwright@latest

The init wizard sets up:

  • tests/ folder
  • playwright.config.ts
  • A GitHub Action template

A Smoke Test¶

ts
7 lines
1// tests/home.spec.ts
2import { test, expect } from "@playwright/test";
3
4test("home page loads and shows hero", async ({ page }) => {
5  await page.goto("/");
6  await expect(page.getByRole("heading", { name: /learn anything/i })).toBeVisible();
7});

A Real Journey¶

ts
19 lines
1// tests/signup.spec.ts
2test("user signs up, enrolls, completes lesson 1", async ({ page }) => {
3  await page.goto("/signup");
4
5  const email = `test+${Date.now()}@example.com`;
6  await page.fill('[name="email"]', email);
7  await page.fill('[name="password"]', "SuperSafe!23");
8  await page.click('button:has-text("Create account")');
9
10  await expect(page).toHaveURL(/\/dashboard/);
11
12  await page.goto("/courses/nextjs-16-complete-developer-guide");
13  await page.click('button:has-text("Enroll")');
14  await expect(page.getByText(/enrolled/i)).toBeVisible();
15
16  await page.click('a:has-text("What\'s New in Next.js 16")');
17  await page.click('button:has-text("Mark complete")');
18  await expect(page.getByText(/lesson complete/i)).toBeVisible();
19});

Auth Setup — Reuse a Logged-In State¶

Reduces test time dramatically:

ts
13 lines
1// tests/setup/auth.setup.ts
2import { test as setup } from "@playwright/test";
3
4const STORAGE = "tests/.auth/user.json";
5
6setup("authenticate", async ({ page }) => {
7  await page.goto("/login");
8  await page.fill('[name="email"]', "test@example.com");
9  await page.fill('[name="password"]', "Password123!");
10  await page.click('button:has-text("Sign in")');
11  await page.waitForURL("/dashboard");
12  await page.context().storageState({ path: STORAGE });
13});

In playwright.config.ts:

ts
8 lines
1projects: [
2  { name: "setup", testMatch: /.*\.setup\.ts/ },
3  {
4    name: "chromium",
5    use: { ...devices["Desktop Chrome"], storageState: "tests/.auth/user.json" },
6    dependencies: ["setup"],
7  },
8],

Now every test starts already logged in.

Network Stubbing¶

ts
3 lines
1await page.route("**/api/courses", (route) => {
2  route.fulfill({ status: 200, json: [{ id: "1", title: "Stub" }] });
3});

Mock flaky third-party calls for deterministic tests.

Running Against the Dev Server¶

playwright.config.ts:

ts
5 lines
1webServer: {
2  command: "npm run dev",
3  url: "http://localhost:3000",
4  reuseExistingServer: !process.env.CI,
5},
bash
4 lines
1npx playwright test                # headless
2npx playwright test --headed       # see the browser
3npx playwright test --ui           # interactive runner
4npx playwright codegen localhost:3000   # record interactions to scaffold a test

What to E2E vs Unit¶

LayerE2EUnit
Critical flows (signup, checkout)✅❌
Edge cases in validation❌✅
Visual regressionsPlaywright visual❌
Permission rules❌✅
Server Action happy paths✅✅

Aim for 5–15 high-leverage E2E tests and dozens of unit tests. Don't try to E2E everything — they're slow.

Previous

Unit & Component Testing with Vitest

Next

Deploying to Vercel

Use ← → arrow keys to navigate between lessons