Test Detect Kit
Production-ready skill that handles auto, detect, testing, framework. Includes structured workflows, validation checks, and reusable patterns for development.
Test Detect Kit
A utility skill that automatically detects the testing framework used in a project and runs the appropriate test commands. Supports all major testing frameworks across JavaScript, TypeScript, Python, Go, Rust, and other ecosystems.
When to Use This Skill
Choose this skill when:
- Running tests in an unfamiliar project and need to detect the right framework
- Setting up test commands in CI/CD for multi-language monorepos
- Switching between projects with different testing setups
- Automating test execution without knowing the project's test tooling
Consider alternatives when:
- Writing new tests → use a testing patterns or TDD skill
- Fixing failing tests → use a test-fixing skill
- Setting up a testing framework from scratch → use a framework-specific skill
- Running performance/load tests → use a performance testing skill
Quick Start
# Detection order for JavaScript/TypeScript projects: # 1. Check package.json scripts.test # 2. Check for vitest.config.* → vitest # 3. Check for jest.config.* → jest # 4. Check for .mocharc.* → mocha # 5. Check for cypress.config.* → cypress # 6. Check for playwright.config.* → playwright # Detection for Python: # 1. Check for pytest.ini or pyproject.toml [tool.pytest] → pytest # 2. Check for setup.cfg [tool:pytest] → pytest # 3. Check for tests/ with unittest pattern → python -m unittest # Detection for other languages: # Go → go test ./... # Rust → cargo test # Java → mvn test or gradle test # Ruby → bundle exec rspec or bundle exec rails test
Core Concepts
Framework Detection Matrix
| Signal | Framework | Run Command |
|---|---|---|
vitest.config.ts | Vitest | npx vitest run |
jest.config.js | Jest | npx jest |
.mocharc.yml | Mocha | npx mocha |
cypress.config.ts | Cypress | npx cypress run |
playwright.config.ts | Playwright | npx playwright test |
pytest.ini | pytest | python -m pytest |
Cargo.toml | Rust tests | cargo test |
go.mod | Go tests | go test ./... |
pom.xml | Maven | mvn test |
build.gradle | Gradle | ./gradlew test |
Intelligent Test Running
// Detection and execution logic interface TestFramework { name: string; configFiles: string[]; runCommand: string; watchCommand: string; filePattern: string; } const frameworks: TestFramework[] = [ { name: 'vitest', configFiles: ['vitest.config.ts', 'vitest.config.js', 'vitest.config.mts'], runCommand: 'npx vitest run', watchCommand: 'npx vitest', filePattern: '**/*.{test,spec}.{ts,tsx,js,jsx}', }, { name: 'jest', configFiles: ['jest.config.js', 'jest.config.ts', 'jest.config.json'], runCommand: 'npx jest', watchCommand: 'npx jest --watch', filePattern: '**/*.{test,spec}.{ts,tsx,js,jsx}', }, { name: 'pytest', configFiles: ['pytest.ini', 'pyproject.toml', 'setup.cfg'], runCommand: 'python -m pytest', watchCommand: 'python -m pytest-watch', filePattern: '**/test_*.py', }, ]; function detectFramework(projectRoot: string): TestFramework | null { for (const fw of frameworks) { if (fw.configFiles.some(f => existsSync(join(projectRoot, f)))) { return fw; } } // Fallback: check package.json scripts const pkg = readPackageJson(projectRoot); if (pkg?.scripts?.test) { return { name: 'npm', runCommand: 'npm test', ...defaults }; } return null; }
Running Specific Tests
# Run specific test file # Vitest/Jest: npx vitest run src/utils/math.test.ts # pytest: python -m pytest tests/test_math.py # Go: go test ./pkg/math/... # Rust: cargo test math::tests # Run tests matching pattern # Vitest/Jest: npx vitest run -t "should calculate" # pytest: python -m pytest -k "test_calculate" # Go: go test -run TestCalculate ./... # Rust: cargo test calculate
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
autoDetect | boolean | true | Auto-detect framework from project files |
preferPackageScript | boolean | true | Prefer package.json test script over direct |
verbose | boolean | false | Run tests with verbose output |
coverage | boolean | false | Enable coverage reporting |
watchMode | boolean | false | Run in watch mode |
failFast | boolean | false | Stop on first test failure |
Best Practices
-
Check package.json test script first — Many projects configure custom test commands with flags, environment variables, and setup scripts. Respect the project's intended test command before falling back to framework detection.
-
Support running individual test files — When debugging a specific test, running the entire suite wastes time. Detect the framework and construct the command to run only the specified file or test name pattern.
-
Report framework detection results clearly — When auto-detecting, tell the user which framework was detected and why. This transparency prevents confusion when the wrong framework is detected in ambiguous projects.
-
Handle monorepos with multiple test frameworks — Monorepos may have Jest in one package and Vitest in another. Detect per-directory rather than per-repository. Use workspace-aware test commands when available.
-
Include coverage flags only when requested — Coverage collection adds significant overhead. Don't enable it by default. When enabled, detect the appropriate coverage tool (c8, istanbul, coverage.py) for the framework.
Common Issues
Wrong framework detected in monorepo — Root-level config files may not apply to nested packages. Detect from the closest ancestor directory containing a config file. If the user specifies a path, detect relative to that path.
Test command fails with "module not found" — The test framework is configured but not installed. Check node_modules/.bin/ or the virtual environment for the binary. Suggest running npm install or pip install -e ".[test]" before retesting.
Config file exists but tests use different framework — Legacy config files can remain after framework migration. Check package.json devDependencies to verify which framework is actually installed. Prefer the installed framework over detected config files.
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Full-Stack Code Reviewer
Comprehensive code review skill that checks for security vulnerabilities, performance issues, accessibility, and best practices across frontend and backend code.
Test Suite Generator
Generates comprehensive test suites with unit tests, integration tests, and edge cases. Supports Jest, Vitest, Pytest, and Go testing.
Pro Architecture Workspace
Battle-tested skill for architectural, decision, making, framework. Includes structured workflows, validation checks, and reusable patterns for development.