contract-testing

Validate JSON contract fixtures against Zod schemas with Vitest.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/dtaborda/startup-saas-template --skill contract-testing-dtaborda
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: contract-testing
Source: https://github.com/dtaborda/startup-saas-template/tree/main/skills/contract-testing
Command: npx skills add https://github.com/dtaborda/startup-saas-template --skill contract-testing-dtaborda

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Shared Zod contracts and their JSON fixtures can drift apart, leading to regression bugs and invalid payload validation; this skill anchors fixtures against every schema to catch those issues early.

Core Features & Use Cases

  • Fixture Validation: Map each shared JSON fixture in packages/contracts/fixtures to its corresponding schema and assert success with Vitest-powered Zod parsing.
  • Regression Guardrails: Enforce creation of fixtures for every contract change, cover both valid and invalid input scenarios, and refuse merging until CI reruns fixture validation.
  • Use Case: When adding or modifying a schema such as LoginRequestSchema, update the fixtures, run the validation suite, and confirm that both the valid fixture and crafted invalid data behave as expected.

Quick Start

Validate the shared JSON fixtures inside packages/contracts against their Zod schemas using the contract-testing patterns before merging any contract changes.

Frequently Asked Questions about contract-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent Zod schema and JSON fixture drift in CI?

Prevent Zod schema and JSON fixture drift by mapping each shared fixture to its corresponding schema and asserting parse success or failure with Vitest. This catches validation regressions before merging any contract changes.

How do I test invalid payloads against Zod schemas using Vitest?

You test invalid payloads by crafting specific invalid JSON fixtures alongside valid ones and asserting that Zod parsing rejects them. This ensures your schema validation suite covers both expected successes and failures.

What is contract testing with Zod fixtures?

Contract testing with Zod fixtures validates shared JSON payloads against defined schemas to catch regressions. It anchors fixtures to schemas, ensuring payload compatibility before CI merges any contract modifications.

Do I need to create fixtures for both valid and invalid schema coverage?

Yes, you need to create fixtures for both valid and invalid schema coverage. Enforcing both scenarios ensures Vitest suites can comprehensively assert Zod schema compatibility and guard against payload validation regressions.

How do I validate shared contracts before merging changes?

Validate shared contracts by running Vitest-powered Zod parsing against all JSON fixtures in the contracts package. This suite acts as a regression guardrail, refusing merges until all fixture validations pass.

Can I use this for regression testing when modifying a LoginRequestSchema?

Yes, you can use this for regression testing when modifying a LoginRequestSchema by updating the corresponding fixtures and running the validation suite to confirm both valid and invalid crafted data behave as expected.