Mengimplementasikan shift-left testing: test di development loop, contract testing, quality engineering practices, dan quality gates

Setelah di episode 24 kita membangun test framework, pada episode ini kita membahas filosofi quality: shift-left — memindahkan testing ke awal development cycle, dari QA-centric ke quality engineering.
Traditional: Develop → Test → QA → Fix
Shift-Left: Plan → Test → Develop → Test → Deploy
↑
Quality embedded di setiap phaseQuality Engineering vs QA:
├── QA: find bugs (reactive)
├── QE: prevent bugs (proactive)
├── Quality is everyone's responsibility
├── Testing integrated di development
└── Metrics-driven improvement// contract/user.contract.ts
export const userContract = {
GET /api/users: {
response: {
200: {
schema: {
type: 'array',
items: {
type: 'object',
required: ['id', 'name', 'email'],
properties: {
id: { type: 'number' },
name: { type: 'string' },
email: { type: 'string', format: 'email' },
},
},
},
},
},
},
};// Validate API response matches contract
test('user API contract', async ({ request }) => {
const response = await request.get('/api/users');
const data = await response.json();
// Validate against contract
expect(data).toMatchSchema(userContract['GET /api/users'].response['200'].schema);
});# .husky/pre-commit
npm run lint
npm run typecheck
npm run test:unit# .github/workflows/pr-checks.yml
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm run test:unit
- run: npm run test:integrationQuality Gates:
├── Code review approved
├── All tests passing
├── Coverage > 80%
├── No critical security issues
├── Performance budget met
└── Documentation updatedQuality Dashboard:
├── Test coverage: 85%
├── Flaky test rate: 1.5%
├── Bug escape rate: 2%
├── Mean time to detect: 5 minutes
├── Mean time to fix: 2 hours
├── Deployment frequency: Daily
└── Change failure rate: 3%Note
Quality engineering bukan hanya tentang testing — juga tentang prevention, detection, dan continuous improvement di setiap phase.
# 1. Setup pre-commit hooks
npx husky init
echo "npm run lint && npm run typecheck && npm run test:unit" > .husky/pre-commit
# 2. Add contract tests
# 3. Configure quality gates di CI
# 4. Track metrics di dashboardDi episode 26 selanjutnya kita akan membahas ekosistem & tren modern 2026 — AI test automation, self-healing, dan tren yang membentuk masa depan QA. Sampai jumpa di episode 26!