Test — Chạy và tạo tests

Chạy test suite, đo coverage, UI testing qua browser, và verify implementations.
Cập nhật bộ claudekit mới: /test-gen đã bỏ, thay bằng /qa-full:tdd:verify (TDD tests + verify), /verify (confirm fix), /run (run command), /test-flakiness (detect flaky tests). Xem cấu trúc skill mới để biết đầy đủ.

Cú pháp


Luồng hoạt động bên trong

/test — Chạy tests

1

Bước 1: Pre-flight Checks

Chạy typecheck (tsc --noEmit) + lint (eslint) để bắt lỗi cú pháp trước.
2

Bước 2: Execute Test Suites

Tự động detect test framework (Jest/Vitest/Mocha/pytest/go test) và chạy. Hỗ trợ: unit tests, integration tests, e2e tests.
3

Bước 3: Coverage Analysis

Đo coverage: lines, branches, functions, statements. So sánh với target (mặc định 80%).
4

Bước 4: Analyze Failures

Nếu có failing tests → phân tích root cause. Kích hoạt ck-debug nếu cần investigation sâu.
5

Bước 5: UI Tests (nếu có frontend)

Kích hoạt ck:chrome-devtools cho:
  • Screenshots, responsive checks
  • Accessibility audits
  • Console error collection
6

Bước 6: Report

Tổng hợp kết quả thành QA report cấu trúc.

/verify — Confirm fix without regression

1

Bước 1: Typecheck

Chạy tsc --noEmit để xác nhận no type errors.
2

Bước 2: Lint

Chạy eslint để xác nhận no lint violations.
3

Bước 3: Build

Chạy build command để xác nhận compiles.
4

Bước 4: Tests

Chạy test suite — so sánh before/after.
5

Bước 5: Report

Tổng hợp verification report: status + changes.

Ví dụ thực tế


So sánh: /test vs /verify vs /qa-full:tdd:verify


So sánh với chat trực tiếp


Khi nào dùng / không dùng


Test Framework hỗ trợ


Kết hợp với QA


Coverage Thresholds

  • KHÔNG BAO GIỜ bỏ qua failing tests — fix root cause, không dùng mocks/cheats/tricks
  • Tất cả critical paths phải có test coverage
  • Validate happy path VÀ error scenarios
  • Tests phải isolation — không phụ thuộc lẫn nhau
  • Tests phải deterministic và reproducible
  • Flaky tests PHẢI fix trước merge — không accept flakiness

Chi tiết lệnh Test (Accordion)

Prefix: /testChạy tất cả tests + typecheck + lint + coverage analysis:
Steps:
  1. Typecheck (tsc --noEmit)
  2. Lint (eslint)
  3. Test execution (Jest/Vitest/pytest auto-detect)
  4. Coverage measurement
  5. Failure analysis (if any)
Output: Test results + coverage report + failure analysis.Khi dùng: Sau implement feature, pre-commit check, coverage monitoring.
Prefix: /verifyTypecheck + lint + build + test, so sánh before/after:
Output:
  • Typecheck: PASS/FAIL
  • Lint: PASS/FAIL
  • Build: PASS/FAIL
  • Tests: X pass, Y fail (compared to before)
  • Regression: detected or none
Khi dùng: Sau /fix hoặc manual code changes, xác nhận không gây regression.
Prefix: /test-flakinessChạy tests múl lần (default 3 runs) để detect tests không stable:
Output:
  • Flaky tests list
  • Failure pattern (fail 2/3 runs, timeout, race condition, etc.)
  • Recommendation to stabilize
Khi dùng: Trước merge critical PRs, khi cần high-reliability test suite.
Prefix: /run "command"Chạy command bất kỳ (npm script, make target, shell) + capture output:
Output: Command output + exit code + timing.Khi dùng: Custom commands, non-standard test runners, CI step verification.
Prefix: /qa-full:tdd:verify hoặc /cook --tddTest-driven development: write tests first, implement code, verify pass:
Workflow:
  1. Generate test cases từ requirements
  2. Tests fail (red)
  3. Implement code to make tests pass (green)
  4. Verify tất cả tests PASS
Output: TDD report + test results + implementation.Khi dùng: Critical code paths, payment/auth, high-risk modules.