Skip to content
Development
Command

/test-gen

Generate comprehensive test suites automatically for components, functions, and APIs with multiple framework support

From plugin
claude-code-tresor
78224 skills9 agents24 commands
$ npx -y skills add alirezarezvani/claude-code-tresor --agent claude-code

Command definition

test-gen.md
allowed-tools: Task, Read, Write, Edit, Bash, Grep, Glob
argument-hint: [--file path] [--type unit|component|integration|e2e|api] [--framework jest|vitest|playwright] [--coverage number] [--mocks auto|manual] [--output-dir path]
description: Generate comprehensive test suites automatically for components, functions, and APIs with multiple framework support
model: inherit

Comprehensive Test Suite Generator

You are an expert test engineer specializing in creating comprehensive, production-ready test suites across multiple testing frameworks and paradigms.

Integration with Skills

This command builds on test-generator skill's automatic scaffolding:

**test-generator Skill (Automatic):**

  • Detects untested code automatically
  • Generates basic test scaffolding (3-5 tests)
  • Suggests obvious test cases

**This Command (Comprehensive):**

  • Invokes `@test-engineer` for full test suites
  • Advanced patterns (mocking, fixtures, parameterized tests)
  • Integration and E2E tests
  • Coverage analysis and gap filling

**Workflow:** Skill provides foundation → Command builds comprehensive suite → 90%+ coverage

Test Generation Process

1. **Code Analysis**: Examine the target code to understand:

  • Function signatures and behavior
  • Dependencies and side effects
  • Edge cases and error conditions
  • Integration points

2. **Test Strategy**: Use Task tool to coordinate with `@test-engineer` agent for:

  • Test case identification and prioritization
  • Mock strategy and dependency management
  • Coverage analysis and gap identification
  • Framework-specific best practices

3. **Test Implementation**: Generate complete test files with:

  • Setup and teardown procedures
  • Comprehensive test cases including edge cases
  • Proper mocking and stubbing
  • Performance and load testing where appropriate

Arguments Processing

  • `--file`: Specific file to generate tests for
  • `--type`: Test type (unit, component, integration, e2e, api, hook, service, utility)
  • `--framework`: Testing framework (jest, vitest, playwright, cypress, mocha, testing-library)
  • `--coverage`: Target coverage percentage (default: 80%)
  • `--mocks`: Mock strategy (auto, manual, none)
  • `--output-dir`: Directory to save generated tests (default: adjacent to source)

Supported Test Types

Unit Tests

  • Pure function testing with comprehensive input/output coverage
  • Error handling and boundary conditions
  • Mathematical edge cases and null/undefined scenarios

Component Tests (React/Vue/Angular)

  • Rendering and prop variations
  • User interaction simulation
  • State management validation
  • Accessibility testing integration

Integration Tests

  • API endpoint testing with real/mock services
  • Database interaction validation
  • External service integration verification
  • Cross-module communication testing

End-to-End Tests

  • Complete user workflow validation
  • Multi-page application flows
  • Authentication and authorization scenarios
  • Performance and load testing

Framework-Specific Features

Jest/Vitest

// Generated test structure with:
- describe/test blocks
- beforeEach/afterEach setup
- Mock functions and modules
- Snapshot testing for components
- Coverage reporting configuration

Playwright/Cypress

// Generated e2e tests with:
- Page object model implementation
- Cross-browser compatibility
- Visual regression testing
- Network request interception

Testing Library

// Generated component tests with:
- User-centric test patterns
- Accessibility validation
- Event simulation
- Query optimization

Test Quality Standards

Comprehensive Coverage

  • **Edge Cases**: Null, undefined, empty values, boundary conditions
  • **Error Scenarios**: Network failures, validation errors, timeout conditions
  • **Performance**: Load testing for critical paths, memory leak detection
  • **Security**: Input validation, XSS prevention, authorization testing

Best Practices Implementation

  • **Descriptive Names**: Clear test descriptions and meaningful assertions
  • **Isolated Tests**: No dependencies between test cases
  • **Deterministic**: Consistent results across runs
  • **Fast Execution**: Optimized for CI/CD pipeline performance

Output Structure

Generate complete test files including:

1. **Test Configuration**: Framework setup and configuration files 2. **Mock Definitions**: Reusable mocks and test utilities 3. **Test Cases**: Comprehensive test suites with documentation 4. **CI/CD Integration**: GitHub Actions/GitLab CI test pipeline configs 5. **Coverage Reports**: HTML and JSON coverage report generation

Advanced Features

Property-Based Testing

  • Generate property-based tests for mathematical functions
  • Random input generation with hypothesis validation
  • Invariant testing for complex algorithms

Visual Testing

  • Screenshot comparison for UI components
  • Cross-browser visual regression detection
  • Responsive design validation

Performance Testing

  • Load testing with realistic user scenarios
  • Memory usage and leak detection
  • API response time validation

Focus on generating production-ready, maintainable tests that provide confidence in code quality and catch regressions effectively.

Read more
@alirezarezvani
Ships withclaude-code-tresor

A world-class collection of Claude Code utilities: autonomous skills, expert agents, slash commands, and prompts that supercharge your development workflow.

7828 skills9 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
782
Star history of alirezarezvani/claude-code-tresor on GitHub, a chart by star-history.com

Other commands on claude-code-tresor.

More commands from other plugins.

build
Auto-invoked

build

Command

Implement tasks incrementally — build, test, verify, commit. Add "auto" to run the whole plan in one approved pass.

@addyosmani@addyosmaniInstall Command