Test detect

From davila7/claude-code-templates · View interactive version

Test detect is an AI agent skill from the GitHub repository davila7/claude-code-templates. Auto-detect testing framework and run relevant tests. Identifies Jest, Vitest, Playwright, Cypress, pytest, Go test, and others. Can run all tests, specific file tests, or generate basic tests for new code. Usage - /test-detect, /test-detect src/auth/login.ts, /test-detect generate src/utils.ts

How to use this skill

Skill file

Test Detect

Automatically detect the testing framework in the current project and run the right tests.

Workflow

Step 1: Detect the testing framework

Check for these files in order (first match wins):

| Check | Framework | Run Command |

|-------|-----------|-------------|

| vitest.config.* exists OR vitest in devDeps | Vitest | npx vitest run |

| jest.config.* exists OR jest in devDeps | Jest | npx jest |

| playwright.config.* exists | Playwright | npx playwright test |

| cypress.config.* exists | Cypress | npx cypress run |

| pytest.ini or conftest.py or pyproject.toml with [tool.pytest] | pytest | python -m pytest |

| go.mod exists | Go test | go test ./... |

| Cargo.toml exists | Rust/cargo | cargo test |

| mix.exs exists | ExUnit | mix test |

| Gemfile with rspec | RSpec | bundle exec rspec |

| package.json has scripts.test | npm test | npm test |

Report the detected framework before proceeding.

Step 2: Parse arguments

Check $ARGUMENTS for the mode:

Step 3: Run full test suite

Run the detected test command. After completion:

Step 4: Run tests for a specific file

Given a source file path, find its test file:

Search strategy (try in order):

  1. __tests__/<filename>.test.<ext> (Jest convention)
  2. <filename>.test.<ext> (co-located)
  3. <filename>.spec.<ext> (alternative convention)
  4. test/<filename>_test.<ext> (Go/Python convention)
  5. tests/test_<filename>.<ext> (pytest convention)
  6. <filename>_test.go (Go convention)

Use Glob to find matches. If found, run only that test file:

| Framework | Command |

|-----------|---------|

| Vitest | npx vitest run <test-file> |

| Jest | npx jest <test-file> |

| Playwright | npx playwright test <test-file> |

| pytest | python -m pytest <test-file> |

| Go | go test -run <TestName> ./<package>/ |

| Cargo | cargo test <test_name> |

If no test file found, ask: "No tests found for this file. Want me to generate them? Run /test-detect generate <file>"

Step 5: Generate tests

Read the source file and analyze:

  1. Identify all exported functions/classes/components
  2. Determine the appropriate test patterns for the framework
  3. Generate a test file with:

Save to the conventional location for the detected framework:

Show the generated file path and ask if the user wants to run the new tests.

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.