Chuyển đến nội dung
Skillpedia
Kiểm thử33k · #8806

test-detect

Skill này làm gì

Skill này tìm công cụ kiểm thử mà dự án của bạn đã dùng, như Jest, pytest hoặc Playwright, rồi chạy các kiểm thử phù hợp. Nó dành cho lập trình viên muốn chạy kiểm thử nhanh và đúng.

Khi nào nên dùng

  • ✓Khi bạn muốn chạy mọi bài kiểm thử trong dự án mà không cần tra lệnh.
  • ✓Khi bạn chỉ muốn chạy kiểm thử cho một file bạn đã thay đổi.
  • ✓Khi bạn cần các kiểm thử cơ bản được viết cho một đoạn code mới.

Liên kết skill

https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/test-detect/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/development/test-detect/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Hãy chạy kiểm thử cho dự án của tôi và cho tôi biết nếu có gì thất bại.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra các file dự án để tìm dấu hiệu như cấu hình Jest hoặc pytest, báo cáo framework nó tìm thấy, rồi chạy lệnh phù hợp cho toàn bộ bộ kiểm thử hoặc một file.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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:

  • No arguments or "all": Run the full test suite (Step 3)
  • File path (e.g., src/auth/login.ts): Run tests for that file (Step 4)
  • "generate" + file path (e.g., generate src/utils.ts): Generate tests (Step 5)

Step 3: Run full test suite

Run the detected test command. After completion:

  • Report total tests, passed, failed, skipped
  • If tests fail, show the first 3 failure messages with file:line references
  • Suggest: "Run /test-detect <failing-file> to investigate a specific failure"

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:
    • Import statements
    • describe block per function/class
    • it/test blocks covering: happy path, edge cases, error cases
    • Framework-appropriate assertions and mocking

Save to the conventional location for the detected framework:

  • Jest/Vitest: __tests__/<filename>.test.<ext> or <filename>.test.<ext> (match existing convention)
  • pytest: tests/test_<filename>.py
  • Go: <filename>_test.go (same directory)
  • RSpec: spec/<filename>_spec.rb

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

Tips

  • If multiple frameworks are detected (e.g., Vitest for unit tests + Playwright for e2e), mention both and default to the unit test framework
  • For monorepos, detect from the closest config file to the current directory
  • If package.json has both test and test:unit/test:e2e scripts, prefer the specific one when context is clear
Câu hỏi thường gặp

Nó nhận diện những công cụ kiểm thử nào?

Nó nêu tên Jest, Vitest, Playwright, Cypress, pytest và Go test, và cũng bao gồm Cargo, ExUnit và RSpec.

Nó có viết được kiểm thử mới không?

Có. Nó có thể tạo các kiểm thử cơ bản cho một file bạn chỉ định.

Nếu nó không tìm thấy framework thì sao?

Nó kiểm tra lần lượt một danh sách các file thiết lập phổ biến, nên một dự án khác thường có thể cần lệnh thủ công.

Chi tiết

Mô tả gốc của tác giả

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

repo: davila7/claude-code-templates

Độ phổ biến

Sao GitHub
33k
Vị trí xếp hạng
#8806
Giấy phép
MIT
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự