Memahami kapan harus mengotomasi testing, tools yang tersedia seperti Playwright dan Cypress, serta framework yang sesuai untuk proyek kalian

Setelah di episode 22 kita mempelajari testing AI/LLM applications, pada episode ini kita mempelajari test automation introduction — kapan harus mengotomasi testing, tools yang tersedia, dan framework yang sesuai. Automation bukan untuk semua situasi, tapi kapan dilakukan dengan benar, bisa meningkatkan efisiensi secara drastis.
Mengapa test automation penting? Karena manual testing tidak scalable untuk regression testing yang berulang. Dengan automation, kalian bisa menjalankan ratusan test cases dalam hitungan menit, bukan berjam-jam.
Automation Decision:
├── Automate JIKA:
│ ├── Test dijalankan berulang kali
│ ├── Test stabil (tidak sering berubah)
│ ├── Test memakan waktu lama manual
│ ├── Test kritis untuk regression
│ └── ROI automation tinggi
├── JANGAN Automate JIKA:
│ ├── Test hanya dijalankan sekali
│ ├── Test sering berubah
│ ├── Test membutuhkan human judgment
│ ├── Test exploratory
│ └── ROI automation rendah
└── Consider:
├── Maintenance cost
├── Learning curve
└── Team expertiseWhat to Automate:
├── Regression Tests:
│ ├── Login/Logout
│ ├── Core business flow
│ └── Critical paths
├── Smoke Tests:
│ ├── Build verification
│ ├── Quick sanity check
│ └── Deployment verification
├── Data-Driven Tests:
│ ├── Multiple input combinations
│ ├── Boundary value testing
│ └── Matrix testing
└── Cross-browser Tests:
├── Same test, multiple browsers
├── Consistent execution
└── Parallel testing| Aspek | Playwright | Cypress |
|---|---|---|
| Browser | Chromium, Firefox, WebKit | Chromium only (Firefox experimental) |
| Speed | Sangat cepat | Cepat |
| Auto-wait | Ya | Manual wait |
| Multi-tab | Ya | Tidak |
| Mobile | Partial | Tidak |
| Learning curve | Sedang | Mudah |
| Community | Growing | Established |
# Install Playwright
npm init playwright@latest
# Install browsers
npx playwright install
# Run tests
npx playwright test
# Open UI mode
npx playwright test --ui# Install Cypress
npm install cypress --save-dev
# Open Cypress
npx cypress open
# Run in headless
npx cypress runNote
Playwright adalah pilihan yang lebih baik untuk testing modern: multi-browser support, auto-wait, dan performa yang lebih baik. Cypress masih bagus untuk pemula dengan learning curve yang lebih rendah.
Page Object Model:
├── pages/
│ ├── LoginPage.js
│ ├── DashboardPage.js
│ └── CheckoutPage.js
├── tests/
│ ├── login.spec.js
│ ├── dashboard.spec.js
│ └── checkout.spec.js
├── fixtures/
│ ├── users.json
│ └── products.json
└── playwright.config.js// pages/LoginPage.js
export class LoginPage {
constructor(page) {
this.page = page;
this.emailInput = page.locator('#email');
this.passwordInput = page.locator('#password');
this.loginButton = page.locator('#login-button');
}
async login(email, password) {
await this.emailInput.fill(email);
await this.passwordInput.fill(password);
await this.loginButton.click();
}
}// tests/login.spec.js
import { test, expect } from '@playwright/test';
import { LoginPage } from '../pages/LoginPage';
test('login with valid credentials', async ({ page }) => {
const loginPage = new LoginPage(page);
await page.goto('https://app.example.com/login');
await loginPage.login('test@example.com', 'password123');
await expect(page).toHaveURL('/dashboard');
});
test('login with invalid credentials', async ({ page }) => {
const loginPage = new LoginPage(page);
await page.goto('https://app.example.com/login');
await loginPage.login('test@example.com', 'wrongpassword');
await expect(page.locator('.error-message')).toBeVisible();
});Tip
Mulai dengan automating smoke tests dan critical path tests. Jangan coba mengotomasi semua test sekaligus. Bertahap lebih baik daripada big bang.
Pada episode 23 ini, kalian telah mempelajari test automation introduction.
Inti yang harus dibawa pulang:
Di episode 24 selanjutnya, kita akan membahas shift-left & continuous quality — bagaimana memulai quality sejak requirement dan quality collaboration dini. Sampai jumpa di episode 24!