Functions
Playwright HTTP request integration
Playwright HTTP assertions exercise real endpoint behavior when a server is running. Set maxRedirects to zero when the initial response status matters, and use an isolated request context for anonymous tests. A response assertion alone does not establish that no database write occurred. Source: https://playwright.dev/docs/api/class-apirequestcontext. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
await request.post(path, { data })Working Example
Example Snippetnextjs
import {test,expect} from '@playwright/test';test('reject invalid quantity',async({request})=>{ const res=await request.post('/api/quote',{data:{quantity:0},maxRedirects:0}); expect(res.status()).toBe(400); expect(res.headers()['content-type']).toContain('application/json'); expect(await res.json()).toEqual({error:'Invalid quantity'});});