test-fixtures

Organize and sanitize API fixtures under test/unit/resources with JSON naming conventions.

6|Updated Feb 20, 2025
One-click install
npx skills add https://github.com/zerobias-org/module --skill test-fixtures-zerobias-org
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-fixtures
Source: https://github.com/zerobias-org/module/tree/main/.claude/skills/test-fixtures
Command: npx skills add https://github.com/zerobias-org/module --skill test-fixtures-zerobias-org

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automates and enforces organized, sanitized, and realistic test fixtures for unit tests, ensuring fixtures reflect real API responses and are free of PII.

Core Features & Use Cases

  • Organize by resource directories under test/unit/resources
  • Enforce naming conventions like mockResponse*.json and mockError*.json
  • Sanitize PII and provide realistic placeholder values
  • Load fixtures in tests and mock HTTP requests with tools like nock
  • Support validation and maintenance workflows for fixtures

Quick Start

Create a test/unit/resources/resource/ directory, add mockResponseN.json and mockErrorN.json files following the naming conventions, and load them in tests with a helper that reads the JSON and mocks HTTP requests.

Frequently Asked Questions about test-fixtures

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

FAQPage Schema
How do I organize and sanitize API fixtures for unit tests?

Unit test fixtures should be organized into resource directories under test/unit/resources, sanitized to remove PII by substituting realistic placeholder values, and formatted with 2-space JSON indentation to ensure reliable and maintainable tests.

How do I mock HTTP requests using nock and JSON fixtures?

Mocking HTTP requests with nock involves loading sanitized JSON fixtures from your test/unit/resources directory and configuring nock interceptors to return those fixtures as mock API responses during unit tests.

What is the best way to structure test fixtures for backend services?

The best way to structure test fixtures for backend services is grouping files by resource under test/unit/resources, enforcing mockResponse*.json and mockError*.json naming conventions, and validating data shapes to accurately reflect real API responses.

How do I validate data shapes in API mock responses?

Validating data shapes in API mock responses involves checking loaded JSON fixtures against expected schemas, ensuring the sanitized test fixtures maintain the correct structure required for reliable fixture-driven unit tests.

Can I use existing JSON files with nock-based mocks?

Yes, you can use existing JSON files with nock-based mocks by loading them from the test/unit/resources directory, ensuring they follow the mockResponse*.json naming convention, and passing the data directly into nock interceptors.

Why do my unit tests fail when API fixtures contain PII?

Unit tests fail when API fixtures contain PII because sensitive data breaks sanitization requirements. Sanitizing fixtures by replacing PII with realistic placeholder values ensures tests remain reliable and compliant.