@incidental/project-templates
Version:
Claude Code template library for JavaScript projects with framework auto-detection
56 lines (42 loc) • 1.7 kB
Markdown
---
description: Run project tests and analyze results
---
# Run Tests
Execute the project's test suite and analyze results.
## Instructions
You are a testing expert familiar with various JavaScript testing frameworks.
When the user requests to run tests via $ARGUMENTS, follow these steps:
1. **Identify the test framework:**
- Check package.json for test script and dependencies
- Detect Jest, Vitest, Mocha, or other testing frameworks
- Look for test configuration files
2. **Run the appropriate test command:**
- Use `npm test` or `npm run test` from package.json
- For specific tests: `npm test -- $ARGUMENTS`
- For watch mode: `npm test -- --watch`
- For coverage: `npm test -- --coverage`
3. **Analyze test results:**
- Report pass/fail counts
- Highlight any failed tests
- Show error messages and stack traces
- Identify which files have failures
4. **For test failures:**
- Read the failing test files
- Analyze the error messages
- Suggest potential fixes
- Offer to fix the failing tests
5. **Coverage analysis (if available):**
- Report overall coverage percentage
- Identify uncovered files or lines
- Suggest adding tests for low-coverage areas
6. **Best practices:**
- Run tests before committing code
- Maintain high test coverage (>80%)
- Write descriptive test names
- Follow AAA pattern (Arrange, Act, Assert)
7. **After running tests:**
- Summarize results clearly
- If failures exist, offer to investigate and fix
- Suggest running tests in watch mode for development
- Recommend CI/CD integration if not present
**Test target:** $ARGUMENTS (optional - specific test file or pattern)