Integration and production server tests
What you need to know
Production server integration tests check real HTTP behavior across routing, validation and application boundaries. They complement unit tests by observing status, headers, response data and persistent effects together.
By the end, you can: verify HTTP and mutation behavior; reset synthetic state.
A direct API request test
import {test,expect} from '@playwright/test';test('reject invalid quantity',async({request})=>{ const res=await request.post('/api/quote',{data:{quantity:0}}); expect(res.status()).toBe(400); expect(res.headers()['content-type']).toContain('application/json'); expect(await res.json()).toEqual({error:'Invalid quantity'});});Expected behavior: Expected 400 with a stable JSON error after a compatible production server is started.
How it works
Run an approved production build with deterministic fixture configuration. Bind the server to loopback and use a dedicated port. Readiness should be an explicit health request or observable condition, with a timeout and cleanup. An HTTP test can assert original redirect status, content type, cache headers, body validation and supported methods. Playwright API requests follow redirects by default; use maxRedirects: 0 on a request to inspect the original redirect and Location header, then test the destination separately. Mutation tests also need a before/after state assertion and an independent reset; a 200 response is not proof of persistence. Use an owned disposable database for durable mutations, and exercise denied writes using real test authentication rather than trusting a user-provided actor field. The V11 fixture intentionally exposes only a stateless quote calculation via POST; it is not a database write or production authorization example. Its contract can be tested independently with a local Node HTTP adapter, but that cannot establish Next.js handler behavior.
Mutation verification plan for a future persistent route
Reset lab database -> capture revision 1 -> authorized mutation -> revision 2Reset -> denied mutation -> still revision 1Reset -> invalid input -> still revision 1Always close connections and discard owned fixtureExpected behavior: The database observations are required for an actual write contract; this batch does not perform those writes.
Common mistake
Do not test with a real production connection string or use a shared database without reset. Do not interpret a mock or standalone HTTP adapter as actual Next.js integration.
Practice and verification
Run the independent quote contract tests, then compare the real production server after dependency approval. Record separate evidence for HTTP, persistence and access denial.
Scope: Proposed Next.js 16.x / React 19, Cache Components disabled unless noted. Framework, browser and component examples are staged; local standalone tests are reported separately. Exact dependency patches and platform contracts pending.
Further reading: Playwright · Cli · Testing