T

Test Detect Kit

Production-ready skill that handles auto, detect, testing, framework. Includes structured workflows, validation checks, and reusable patterns for development.

SkillClipticsdevelopmentv1.0.0MIT
0 views0 copies

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

SignalFrameworkRun Command
vitest.config.tsVitestnpx vitest run
jest.config.jsJestnpx jest
.mocharc.ymlMochanpx mocha
cypress.config.tsCypressnpx cypress run
playwright.config.tsPlaywrightnpx playwright test
pytest.inipytestpython -m pytest
Cargo.tomlRust testscargo test
go.modGo testsgo test ./...
pom.xmlMavenmvn test
build.gradleGradle./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

ParameterTypeDefaultDescription
autoDetectbooleantrueAuto-detect framework from project files
preferPackageScriptbooleantruePrefer package.json test script over direct
verbosebooleanfalseRun tests with verbose output
coveragebooleanfalseEnable coverage reporting
watchModebooleanfalseRun in watch mode
failFastbooleanfalseStop on first test failure

Best Practices

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates