Test Case Generator

    1

    Automated generation of unit and integration tests with mandatory edge-case coverage and dependency mocking.

    Free

    7 installsSecurity scanned

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+22 more

    Test Case Generator

    Example session with this skill installed

    Generate Vitest tests for a TypeScript function that fetches user data from a REST API and calculates their loyalty points based on purchase history. Mock the fetch call.

    • Read your context and instructions
    • Compiled the test case generator

    I have analyzed the loyalty calculation logic and the API dependency. I have generated a Vitest suite that covers successful data retrieval, API failure states, and boundary values for point calculation.

    Test Generation Report

    • Target: calculateLoyaltyPoints
    • Framework: Vitest

    Coverage Strategy: Success path with mocked API, 404 error handling, and edge cases for zero/negative purchase history.

    import { describe, it, expect, vi, beforeEach } from 'vitest';
    import { calculateLoyaltyPoints } from './loyaltyService';
    
    describe('calculateLoyaltyPoints', () => {
      beforeEach(() => {
        vi.stubGlobal('fetch', vi.fn());
      });
    
      it('should return 100 points for a user with $1000 spend', async () => {
        const mockUser = { id: 1, totalSpent: 1000 };
        (fetch as any).mockResolvedValue({
          ok: true,
          json: () => Promise.resolve(mockUser),
        });
    
        const result = await calculateLoyaltyPoints(1);
        expect(result).toBe(100);
      });
    
      it('should throw an error when the API returns a 404', async () => {
        (fetch as any).mockResolvedValue({
          ok: false,
          status: 404,
        });
    
        await expect(calculateLoyaltyPoints(99)).rejects.toThrow('User not found');
      });
    
      it('should return 0 points for negative spend values (edge case)', async () => {
        const mockUser = { id: 2, totalSpent: -50 };
        (fetch as any).mockResolvedValue({
          ok: true,
          json: () => Promise.resolve(mockUser),
        });
    
        const result = await calculateLoyaltyPoints(2);
        expect(result).toBe(0);
      });
    });
    

    Self-Check

    • Happy path covered
    • Edge cases included
    • External dependencies mocked
    • Syntax matches requested framework

    Next steps

    1. Copy the code into loyaltyService.test.ts.
    2. Run npx vitest to verify the execution.
    3. Update the mockUser object if your actual API schema includes additional required fields.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The problem

    Writing tests is often the slowest part of development. Developers frequently skip edge cases or struggle with complex mocking setups, leading to fragile codebases and regressions.

    What it does

    • Analyzes function signatures to identify necessary inputs, outputs, and dependencies.
    • Generates "happy path" unit tests to verify core functionality works as expected.
    • Produces specific test cases for edge cases like null inputs, empty arrays, and timeouts.
    • Configures standard mocking patterns for external APIs, databases, and file systems.
    • Adapts output syntax to your specific testing framework, including Vitest, Jest, and Pytest.

    Frameworks & tools

    Jest, Vitest, Pytest, Mocha, Cypress, and standard mocking libraries like unittest.mock or vi.fn().

    Why this beats prompting it yourself

    General-purpose prompts often miss subtle failure modes or provide hallucinated mocking syntax. This skill enforces a strict analysis phase to ensure all external dependencies are properly isolated and every function is stress-tested with boundary values.

    Use cases

    • Generating a full test suite for a newly written React component or API endpoint.
    • Creating regression tests before refactoring legacy functions.
    • Quickly scaffolding mocks for third-party service integrations.
    • Ensuring 100% branch coverage for complex utility functions.

    How to use

    Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    7 installs

    Downloaded by developers to date

    Free forever

    No account required to browse

    Trust & safety

    Security scanned

    Verified clean 1 month ago

    • Free to download with an account

    Listed1 month ago

    What's inside

    Frequently Asked Questions