원클릭으로
testing-strategy
Panduan membuat unit test, feature test, dan e2e test sesuai pola codebase.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Panduan membuat unit test, feature test, dan e2e test sesuai pola codebase.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Workflow untuk fitur non-standar seperti Dashboard, Settings, User Management, atau Halaman Khusus.
Panduan refactor khusus Backend (Laravel)
Panduan refactor E2E test per modul menggunakan shared test factories, termasuk pertimbangan refactoring frontend/backend agar testing konsisten.
Panduan refactor khusus Frontend (React SPA)
Panduan membuat migration, seeder, dan factory sesuai standar Laravel.
Workflow untuk membuat fitur CRUD kompleks dengan relasi foreign key, filter multi-field, dan komponen frontend terpisah.
| name | Testing Strategy |
| description | Panduan membuat unit test, feature test, dan e2e test sesuai pola codebase. |
Gunakan skill ini untuk membuat test yang konsisten dengan pola testing di codebase.
| Tool | Kapan Digunakan |
|---|---|
activate_laravel_logging_and_debugging_tools() | Aktifkan tool error/log saat test gagal |
mcp_laravel-boost_tinker | Inspect test data atau debug code snippets |
activate_laravel_logging_and_debugging_tools() | Aktifkan tool browser log untuk debug E2E frontend errors |
read_file | Baca file test referensi |
| Tipe | Lokasi | Fokus |
|---|---|---|
| Feature Test | tests/Feature/ | API endpoints, HTTP responses |
| Unit Test | tests/Unit/ | Actions, Requests, Resources |
| E2E Test | tests/e2e/ | User journey, browser |
| Tipe | Lokasi | Contoh |
|---|---|---|
| Feature | tests/Feature/ | EmployeeControllerTest.php |
| Unit Actions | tests/Unit/Actions/{Module}/ | IndexEmployeesActionTest.php |
| Unit Requests | tests/Unit/Requests/{Module}/ | StoreEmployeeRequestTest.php |
| E2E | tests/e2e/{module}/ | add-employee.spec.ts |
# Baca file test existing untuk pattern:
read_file(filePath: "/absolute/path/to/project/tests/Feature/EmployeeControllerTest.php", startLine: 1, endLine: 260)
read_file(filePath: "/absolute/path/to/project/tests/e2e/employees/add-employee.spec.ts", startLine: 1, endLine: 260)
# Debug test failure:
activate_laravel_logging_and_debugging_tools()
# lalu gunakan tool error/log atau browser log Laravel yang tersedia
| Pattern | File Referensi |
|---|---|
| Feature Test | tests/Feature/EmployeeControllerTest.php |
| Action Unit Test | tests/Unit/Actions/Employees/IndexEmployeesActionTest.php |
| E2E Test | tests/e2e/employees/add-employee.spec.ts |
[!IMPORTANT] Auth: WAJIB gunakan
Sanctum::actingAs($user)— bukanactingAs($user)
Assertions: GunakanassertJson(),assertJsonStructure(),assertOk()— bukanassertInertia()
Imports: Import class yang dipakai (Sanctum,Storage,Carbon,Rule, model terkait) di header file, lalu gunakan short name. Hindari FQCN seperti\Laravel\Sanctum\Sanctum,\Illuminate\Support\Facades\Storage, atau\Carbon\Carbondi body test.
Ini karena arsitektur API-only (stateless Bearer Token), bukan session-based.
Test cases per method:
| Method | Test Cases |
|---|---|
index | List, pagination, search, filter, sort |
store | Success (201), validation error (422) |
update | Success, validation error |
destroy | Success (204), not found (404) |
$action = new IndexEmployeesAction(new EmployeeFilterService());
$result = $action->execute($request);
$this->assertInstanceOf(LengthAwarePaginator::class, $result);
$request = new StoreEmployeeRequest();
$validator = Validator::make([], $request->rules());
$this->assertTrue($validator->fails());
PENTING: Untuk refactoring E2E test existing, gunakan skill
refactor-e2e.
| Flow | Test Cases |
|---|---|
| Search | Search entity by identifier |
| Filters | Open filter dialog, apply filter |
| Add | Open modal, fill form, submit, see new item |
| View | Click actions → View, verify detail |
| Edit | Click actions → Edit, modify, save, verify |
| Export | Click export, download file, verify columns via ExcelJS |
| Checkbox | Body checkbox visible, header checkbox NOT visible |
| Sorting | Click all sortable column headers |
| Delete | Click actions → Delete, confirm, item gone |
Selectors: Gunakan getByRole(), getByLabel(), getByPlaceholder() — bukan data-testid
// turbo-all
# Lint / formatter guard
./vendor/bin/sail bin duster fix
# Backend tests
./vendor/bin/sail test
# Specific module
./vendor/bin/sail test --filter=Employee
# E2E tests
./vendor/bin/sail npm run test:e2e
Jika test gagal:
activate_laravel_logging_and_debugging_tools()
# lalu gunakan tool error/log atau browser log Laravel yang tersedia