@tpmjs/tools-test-case-generate
Generates comprehensive test case outlines from a function signature. Analyzes parameter types and return type to create normal test cases, edge cases, and error cases. Provides testing recommendations and identifies coverage areas. Useful for quickly scaffolding test suites and ensuring thorough test coverage.
Test @tpmjs/tools-test-case-generate (testCaseGenerateTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-test-case-generatepnpm add @tpmjs/tools-test-case-generateyarn add @tpmjs/tools-test-case-generatebun add @tpmjs/tools-test-case-generatedeno add npm:@tpmjs/tools-test-case-generateimport { testCaseGenerateTool } from '@tpmjs/tools-test-case-generate';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { testCaseGenerateTool } from '@tpmjs/tools-test-case-generate';
const result = await generateText({
model: openai('gpt-4o'),
tools: { testCaseGenerateTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
functionNamestringName of the function to generate tests for
paramsarrayArray of function parameters with name and type
returnTypestringReturn type of the function (e.g., boolean, Promise<User>, void)
Schema extracted: 1/1/2026, 8:18:15 AM
Generates comprehensive test case outlines from function signatures, including normal cases, edge cases, and error cases.
npm install @tpmjs/tools-test-case-generate
import { testCaseGenerateTool } from '@tpmjs/tools-test-case-generate'; const result = await testCaseGenerateTool.execute({ functionName: 'calculateTotal', params: [ { name: 'items', type: 'Array<number>' }, { name: 'discount', type: 'number' }, { name: 'taxRate', type: 'optional number' } ], returnType: 'number' }); console.log(result); // { // testCases: [ // { // name: 'should handle valid inputs', // description: 'Test calculateTotal with standard valid inputs', // input: { items: [1, 2, 3], discount: 42, taxRate: 42 }, // expectedBehavior: 'Should return number successfully', // category: 'normal' // }, // // ... more test cases // ], // edgeCases: [ // { // name: 'should handle items as empty array', // description: 'Test calculateTotal when items is empty array', // input: { items: [], discount: 42, taxRate: 42 }, // expectedBehavior: 'Should handle gracefully and return number', // category: 'edge' // }, // // ... more edge cases // ], // summary: { // totalCases: 25, // normalCases: 1, // edgeCases: 18, // errorCases: 6, // coverageAreas: [ // 'Happy path with valid inputs', // 'Boundary values (min/max)', // 'Array edge cases (empty, single element, large size)', // 'Type validation and error handling' // ] // }, // recommendations: [ // 'Verify immutability - ensure function does not mutate input arrays', // 'Test floating-point precision edge cases (e.g., 0.1 + 0.2)', // 'Use property-based testing for comprehensive coverage', // // ... more recommendations // ] // }
The tool intelligently generates test cases for:
string, number, booleanArray<T>, T[]object, Record<K,V>, custom typesDate, date stringsPromise<T>, async functionsoptional T, T?, T | null | undefined{ functionName: string; // Name of the function params: Array<{ name: string; // Parameter name type: string; // Parameter type (TypeScript syntax) }>; returnType: string; // Return type }
{ testCases: Array<{ name: string; // Test case name description: string; // Detailed description input: Record<string, any>; // Test input values expectedBehavior: string; // Expected outcome category: 'normal' | 'edge' | 'error'; }>; edgeCases: TestCase[]; // Additional edge cases summary: { totalCases: number; normalCases: number; edgeCases: number; errorCases: number; coverageAreas: string[]; // Areas of coverage }; recommendations: string[]; // Testing best practices }
const result = await testCaseGenerateTool.execute({ functionName: 'isValidEmail', params: [ { name: 'email', type: 'string' } ], returnType: 'boolean' }); // Generates tests for: // - Valid email // - Empty string // - Whitespace // - Very long email // - Unicode characters
const result = await testCaseGenerateTool.execute({ functionName: 'fetchUser', params: [ { name: 'userId', type: 'string' } ], returnType: 'Promise<User>' }); // Generates additional async tests: // - Concurrent calls // - Timeout scenarios // - Promise rejection
const result = await testCaseGenerateTool.execute({ functionName: 'processData', params: [ { name: 'data', type: 'Array<Record<string, any>>' }, { name: 'options', type: 'optional object' } ], returnType: 'object' }); // Generates comprehensive coverage including: // - Empty arrays // - Large datasets // - Nested objects // - Missing optional params // - Immutability tests
MIT
Downloads/month
0
Quality Score