Mock gen

From berkcangumusisik/claude-code-practices · View interactive version

Mock gen is an AI agent skill from the GitHub repository berkcangumusisik/claude-code-practices. Generates mock data factories and API mocks for testing

How to use this skill

Skill file

Generate Mocks

Target type/interface: $ARGUMENTS

  1. Find the type definition:
grep -rn "interface $ARGUMENTS\|type $ARGUMENTS\s*=" src/ --include="*.ts" | head -5
  1. Read the full type definition.
  1. Generate a factory function:
// Generated mock factory
export function create$ARGUMENTS(overrides?: Partial<$ARGUMENTS>): $ARGUMENTS {
  return {
    id: faker.string.uuid(),
    name: faker.person.fullName(),
    email: faker.internet.email(),
    createdAt: faker.date.recent(),
    // ...all fields
    ...overrides,
  }
}
  1. If faker or @faker-js/faker is not in the project, use inline test data patterns instead.
  1. Also generate:
  1. Place in src/__mocks__/ or src/testing/factories/ - match project convention.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.