Testing
Ringkasan
Sutomo menggunakan Pest v4 untuk testing PHP dan Vitest untuk testing JavaScript frontend. Keduanya terkonfigurasi dengan coverage reporting.
Stack
| Layer | Framework | Config |
|---|---|---|
| PHP (Unit + Feature) | Pest v4 | phpunit.xml |
| PHP (E2E) | Playwright | playwright.config.ts |
| JavaScript (Unit) | Vitest | vitest.config.ts |
| JavaScript (E2E) | Playwright | playwright.config.ts |
Coverage Standard
| Metrik | Target Minimal |
|---|---|
| Lines | 75% |
| Methods | 80% |
| Branches | 60% |
Laporan coverage: tests/coverage-reports/html/index.html
Menjalankan Test
PHP
bash
composer run test # Semua
php artisan test --compact --filter=Nama # Spesifik
php artisan test --coverage # Dengan coverageFrontend
bash
npm run test:unit # Semua Vitest
npx vitest run path/to/test # SpesifikE2E
bash
npm run test:e2e # Playwright
npm run test:e2e:ui # Mode UICI
bash
composer run ci:check # lint → format → types → testMembuat Test
PHP
bash
php artisan make:test --pest NamaTest # Feature
php artisan make:test --pest --unit NamaTest # UnitFrontend
Buat file di __tests__/ dalam modul yang sama.
File Penting
| File | Tujuan |
|---|---|
phpunit.xml | Konfigurasi PHPUnit/Pest |
vitest.config.ts | Konfigurasi Vitest |
playwright.config.ts | Konfigurasi Playwright |
tests/Unit/ | Unit test |
tests/Feature/ | Feature test |
tests/e2e/ | E2E test |