DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to add API contract tests with Zod validation and fixtures with Agentic Playwright

Write API tests using the apiRequest fixture, Zod schema checks, and setup and teardown helper fixtures.

Short answer: Scaffold the project with npm create agentic-playwright . -- --demo if you have not already; then read the API Testing section of the README to see how the apiRequest fixture and helper fixtures are used; ask the assistant to write an API test for <api-endpoint> using the apiRequest fixture and a Zod schema. All steps.

Who it is forA backend or QA engineer who needs to check that API responses match an expected contract as part of the same test suite.

The problemAPI checks written by hand often lack schema validation and cleanup, so tests leave data behind or pass with malformed responses.

The outcomeAPI tests that call endpoints through the apiRequest fixture, validate responses with Zod schemas, and use helper fixtures for setup and teardown.

What you need first

  • Node.js v22.x or later
  • npm v10.x or later
  • An empty directory or empty git repo for the test project
  • A web application URL to test, or the --demo option to try the bundled demo app

Steps

  1. Scaffold the project with npm create agentic-playwright . -- --demo if you have not already.
  2. Read the API Testing section of the README to see how the apiRequest fixture and helper fixtures are used.
  3. Ask the assistant to write an API test for <api-endpoint> using the apiRequest fixture and a Zod schema.
  4. Run npm test and confirm the API test passes against your environment.

Prompt for your agent

In the agentic-playwright repo, write an API test for <api-endpoint> using the apiRequest fixture and a Zod schema, with setup and teardown fixtures. Expected output: a passing API spec that validates the response shape. Verify that the schema is defined with Zod and that `npm test` passes.

Caveat. The README gives the fixture names but not endpoint details, so you must supply the real API URL and environment values in the env files.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for idavidov13/agentic-playwright and "Add API contract tests with Zod validation and fixtures"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer