OpenParable
Skip to content
← Back to skills

Test Suite Generator

Testing & Quality
test-suite-generator

Test Suite Generator is an Agent Skill for testing & quality published in the majiayu000/claude-skill-registry repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Generates comprehensive test suites for components, hooks, and utilities with proper mocking and assertions.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/majiayu000/claude-skill-registry/blob/HEAD/skills/data/test-suite-generator/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/test-suite-generator, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Test Suite Generator Skill

When to Use

  • User needs tests for a new component
  • User wants to add tests for utility functions
  • User needs integration tests for API routes
  • User asks to set up testing patterns

What This Skill Does

  1. Determines appropriate test types (unit, integration, e2e)
  2. Sets up test files with proper structure
  3. Creates mocks for dependencies
  4. Writes comprehensive test cases
  5. Adds edge case coverage

Component Testing Pattern

import { render, screen, fireEvent } from '@testing-library/react-native';
import { ActivityCard } from './ActivityCard';
import type { Activity } from '@repo/core';

describe('ActivityCard', () => {
  const mockActivity: Activity = {
    id: '1',
    name: 'Morning Run',
    type: 'run',
    distance: 5000,
    duration: 1800,
    startTime: new Date(),
  };

  it('renders activity name and stats', () => {
    render(<ActivityCard activity={mockActivity} />);

    expect(screen.getByText('Morning Run')).toBeTruthy();
    expect(screen.getByText('5.00 km')).toBeTruthy();
    expect(screen.getByText('30:00')).toBeTruthy();
  });

  it('calls onPress when pressed', () => {
    const onPress = jest.fn();
    render(<ActivityCard activity={mockActivity} onPress={onPress} />);

    fireEvent.press(screen.getByRole('button'));
    expect(onPress).toHaveBeenCalledWith('1');
  });
});

Hook Testing Pattern

import { renderHook, waitFor } from "@testing-library/react-native";
import { useActivityRecorder } from "./useActivityRecorder";

describe("useActivityRecorder", () => {
  it("starts in ready state", () => {
    const { result } = renderHook(() => useActivityRecorder("running"));

    expect(result.current.state).toBe("ready");
  });

  it("transitions to recording when started", async () => {
    const { result } = renderHook(() => useActivityRecorder("running"));

    act(() => {
      result.current.start();
    });

    await waitFor(() => {
      expect(result.current.state).toBe("recording");
    });
  });
});

Utility Function Testing

import { calculateTSS } from "./calculations";

describe("calculateTSS", () => {
  it("calculates TSS correctly for 1 hour at FTP", () => {
    const tss = calculateTSS({
      normalizedPower: 250,
      duration: 3600,
      ftp: 250,
    });

    expect(tss).toBe(100);
  });

  it("returns 0 for zero duration", () => {
    const tss = calculateTSS({
      normalizedPower: 250,
      duration: 0,
      ftp: 250,
    });

    expect(tss).toBe(0);
  });
});

Test Coverage Requirements

  • Happy path tests
  • Edge cases (null, undefined, empty)
  • Error conditions
  • Boundary values
  • Async operations
  • User interactions