Generate Tests
Generate a complete test file for a specified source file or component. Use when the user explicitly asks to write, create, or generate tests for a specific file.
Before you use this component
This is a third-party source bundle, not an installation into your account. UI Discovery has checked the available redistribution license evidence; runtime behavior has not been tested. Review all files, use a disposable project first, and do not enable scripts or hooks until you understand their permissions.
Some integrations require separately installed software, API keys or paid services. Credentials and subscriptions are not included. These are Claude Code resources; other clients may require adaptation.
Extract the ZIP into a temporary folder, inspect its entry file and supporting resources, then follow the original instructions. Do not overwrite an existing project configuration blindly. Keep the bundled license and attribution notices.
- Source publisher
- Claude Code Templates
- Creator supplied by source
- Not listed in source
- Pinned source version
- a344359459263d73d8948651c789244093c02e4e
- License evidence
- LICENSE
Source preview
cli-tool/components/commands/testing/generate-tests.md
--- allowed-tools: Read, Write, Edit, Bash argument-hint: [file-path] | [component-name] description: Generate a complete test file for a specified source file or component. Use when the user explicitly asks to write, create, or generate tests for a specific file. --- # Generate Tests Generate comprehensive test suite for: $ARGUMENTS ## Current Testing Setup - Test framework: !`cat package.json 2>/dev/null | grep -E '"jest"|"vitest"|"mocha"|"jasmine"' | head -3 || cat jest.config.* vitest.config.* 2>/dev/null | head -5 || echo "Framework not detected"` - Existing tests: !`find . -name "*.test.*" -o -name "*.spec.*" | head -5` - Test coverage: !`npm run test:coverage 2>/dev/null || echo "No coverage script"` - Target: if $ARGUMENTS is a file path, read it with @$ARGUMENTS; if it is a component name, search for it with Grep before writing tests ## Test Generation Framework 1. **Analyze** the target file/component structure — identify all exported functions, classes, methods, and their signatures 2. **Strategy** — examine existing test patterns in the project; choose unit vs integration scope; identify critical paths and error scenarios 3. **Mock Design** — map all external dependencies (I/O, APIs, timers, dates); create factories for test data; plan cleanup for async operations 4. **Unit Tests** — write isolated tests per function/method covering happy path, edge cases, and error conditions; follow AAA pattern (Arrange, Act, Assert) 5. **Integration Tests** — test component interactions, API layers with mocked responses, and end-to-end user workflows where applicable 6. **Quality Check** — verify naming describes behavior not implementation; confirm 80%+ coverage on critical business logic; ensure test isolation ## Framework-Specific Guidance - **React**: Component testing with React Testing Library; test user interactions and rendering - **Vue**: Component testing with Vue Test Utils; test props, events, and slots - **Angular**: Component and service testing with TestBed; test dependency injection - **Node.js**: API endpoint and middleware testing; test request/response cycles - **Python**: `pytest` with fixtures, `unittest.mock` for patching, `pytest-cov` for coverage - **Go**: Table-driven tests in `_test.go` files, `testify/assert` for assertions, subtests via `t.Run()` - **Rust**: `#[cfg(test)]` modules, `#[test]` attributes, `mockall` for mocking ## Best Practices - Follow AAA pattern (Arrange, Act, Assert) - 80%+ coverage; prioritize critical business logic and error paths - Mock external I/O; use factories for test data - Naming: describe what the function does, not implementation details
Preview capped at 60,000 characters. Download the bundle for every original file and notice.
Read the redistribution license
MIT License Copyright (c) 2025 Daniel (San) Ávila Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Bundle SHA-256: 44fa2c8dfd750e6c803a7d1334fb1d63920899f01d7279bde5402faf2239368e. Files are served as downloads and are never executed by this page.