--- name: test-gen trigger: /test gen description: Generate unit, integration, and E2E tests from requirements or code --- # Skill: Generate Tests ## Trigger `/test gen [file path, module, or feature description]` ## Description Generate comprehensive test suites for the specified target using Jest and React Testing Library. ## Inputs - target: string, file path, module name, or feature description (required) - type: string, test type: unit, integration, e2e, or all (optional, defaults to unit) ## Process 1. Read the target code and its existing tests 2. Read acceptance criteria from requirements if available 3. Identify untested code paths using coverage analysis 4. Generate tests based on type: - **Unit**: Jest tests for functions and React components using React Testing Library - **Integration**: API endpoint tests using supertest; database interaction tests - **E2E**: Critical user journey tests 5. Include for each test: - Happy path - Edge cases (boundary values, empty inputs, null) - Error conditions (invalid inputs, network failures, timeout) - Security cases: injection patterns, auth boundaries, invalid tokens 6. Use deterministic test data (no random seeds without explicit config) 7. Apply project test conventions (describe/it pattern, fixture usage) 8. Mark security tests with `[security-test]` comment for traceability 9. Run the generated tests to verify they pass 10. Report coverage delta ## Output Test files written to the appropriate `__tests__/` or `.test.ts` location. Coverage report. ## Autonomy - Tier 1: generating and running tests ## Error Handling - If target code does not exist: inform user - If generated tests fail: diagnose whether the test or the code is wrong; report finding