Skip to content

Testing

Ringkasan

Sutomo menggunakan Pest v4 untuk testing PHP dan Vitest untuk testing JavaScript frontend. Keduanya terkonfigurasi dengan coverage reporting.


Stack

LayerFrameworkConfig
PHP (Unit + Feature)Pest v4phpunit.xml
PHP (E2E)Playwrightplaywright.config.ts
JavaScript (Unit)Vitestvitest.config.ts
JavaScript (E2E)Playwrightplaywright.config.ts

Coverage Standard

MetrikTarget Minimal
Lines75%
Methods80%
Branches60%

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 coverage

Frontend

bash
npm run test:unit              # Semua Vitest
npx vitest run path/to/test    # Spesifik

E2E

bash
npm run test:e2e               # Playwright
npm run test:e2e:ui            # Mode UI

CI

bash
composer run ci:check  # lint → format → types → test

Membuat Test

PHP

bash
php artisan make:test --pest NamaTest          # Feature
php artisan make:test --pest --unit NamaTest   # Unit

Frontend

Buat file di __tests__/ dalam modul yang sama.


File Penting

FileTujuan
phpunit.xmlKonfigurasi PHPUnit/Pest
vitest.config.tsKonfigurasi Vitest
playwright.config.tsKonfigurasi Playwright
tests/Unit/Unit test
tests/Feature/Feature test
tests/e2e/E2E test