test-infrastructure

JasonPaff's avatarfrom JasonPaff

Enforces Head Shakers test infrastructure conventions for factories, MSW handlers, mock data, Page Objects, and shared test utilities.

⭐1stars🔀0forks📁View on GitHub🕐Updated Dec 5, 2025

When & Why to Use This Skill

This Claude skill automates and enforces standardized test infrastructure conventions, including factories, MSW handlers, mock data, and Page Object Models. It ensures that testing foundations are reusable, maintainable, and consistent across the entire codebase, significantly improving the efficiency of automated software testing workflows.

Use Cases

  • Standardizing Test Factories: Automatically generate async factory functions for database entities with support for unique IDs and attribute overrides.
  • API Mocking with MSW: Set up Mock Service Worker handlers using consistent HTTP response patterns to simulate backend APIs during development and testing.
  • E2E Page Object Implementation: Create structured Page Object Model (POM) classes that extend base classes and utilize standardized element locators for reliable end-to-end tests.
  • Mock Data Generation: Produce typed and realistic mock data sets, including edge case variations, to ensure comprehensive unit and integration test coverage.
  • Maintaining Test Utilities: Enforce naming and export patterns for shared test helpers and utilities to prevent duplication and technical debt in the test suite.
nametest-infrastructure
descriptionEnforces project test infrastructure conventions for factories, MSW handlers, mock data, Page Objects, and shared test utilities.

Test Infrastructure Skill

Purpose

This skill provides test infrastructure conventions for creating reusable testing foundations including factories, MSW handlers, mock data, and Page Object Model classes.

Activation

This skill activates when:

  • Creating or modifying files in tests/fixtures/
  • Creating or modifying files in tests/mocks/
  • Creating or modifying files in tests/helpers/
  • Creating or modifying Page Objects in tests/e2e/pages/
  • Creating or modifying E2E helpers in tests/e2e/helpers/

File Patterns

  • tests/fixtures/**/*.factory.ts
  • tests/mocks/**/*.handlers.ts
  • tests/mocks/**/*.mock.ts
  • tests/mocks/data/**/*.mock.ts
  • tests/e2e/pages/**/*.page.ts
  • tests/e2e/helpers/**/*.ts
  • tests/helpers/**/*.ts

Workflow

  1. Detect infrastructure work (file path matches patterns above)
  2. Load references/Test-Infrastructure-Conventions.md
  3. Also load testing-base skill for shared conventions
  4. Apply infrastructure patterns for the specific type
  5. Ensure consistent naming and export patterns

Key Patterns (REQUIRED)

Factories

  • Async functions returning database entities
  • Accept overrides parameter for customization
  • Generate unique IDs using timestamps
  • Export named factory functions

MSW Handlers

  • Use http from MSW for route handlers
  • Return HttpResponse.json() for JSON responses
  • Export handlers array for server setup

Page Objects

  • Extend BasePage class
  • Define abstract url property
  • Use byTestId helper for element location

Mock Data

  • Export typed mock objects
  • Use realistic data patterns
  • Include edge case variations

References

  • references/Test-Infrastructure-Conventions.md - Complete infrastructure conventions