Install this agent skill to your local

pnpm dlx add-skill https://github.com/vuralserhat86/antigravity-agentic-skills/tree/HEAD/skills/testing

Skill Files

Browse the full folder contents for testing.

Download Skill

Loading file tree…

skills/testing/SKILL.md

Skill Metadata

Name
testing
Description
Kapsamlı test stratejileri ve 2025 test araçları. Unit, integration, e2e ve visual testing.

Testing Skill - Kalite Güvence ve Test Stratejileri

Yazılım kalitesini sağlamak için sistematik test yaklaşımları. 2025 modern test araçları ve piramit test stratejisi.


📋 İçindekiler

  1. Test Piramidi
  2. Unit Testing (Jest)
  3. Integration Testing
  4. E2E Testing (Playwright)
  5. Visual Regression Testing
  6. TDD (Test Driven Development)
  7. Test Yazım Kuralları
  8. Kontrol Listesi
  9. Yapma Listesi
  10. Mutlaka Yap Listesi

1. Test Piramidi

      / \
     /E2E\  ← En az (Yavaş, Pahalı, Kırılgan)
    /-----\
   / INTEGR\ ← Orta (Hız ve Güven dengesi)
  /---------\
 /   UNIT    \ ← En çok (Hızlı, Ucuz, İzole)
/-------------\

| Tip | Kapsam | Hız | Maliyet | |-----|--------|-----|---------| | Unit | Fonksiyon/Component | ⚡⚡⚡ | 💸 | | Integration | DB/API/Module arası | ⚡⚡ | 💸💸 | | E2E | Tam kullanıcı akışı | ⚡ | 💸💸💸 |


2. Unit Testing (Jest)

2.1 Temel Test Yapısı

import { sum } from './math';

describe('sum function', () => {
  test('adds 1 + 2 to equal 3', () => {
    expect(sum(1, 2)).toBe(3);
  });

  test('handles zero correctly', () => {
    expect(sum(0, 0)).toBe(0);
  });
});

2.2 Mocking

// Service mock'lama
jest.mock('./apiService');
import { fetchData } from './apiService';

test('should use mocked data', async () => {
  (fetchData as jest.Mock).mockResolvedValue({ id: 1, name: 'Test' });
  const data = await getServiceData();
  expect(data.name).toBe('Test');
});

3. Integration Testing

3.1 API Integration

import request from 'supertest';
import app from './app';

describe('POST /api/users', () => {
  test('should create a new user and return it', async () => {
    const response = await request(app)
      .post('/api/users')
      .send({ email: 'test@example.com', name: 'Test' });

    expect(response.status).toBe(201);
    expect(response.body.email).toBe('test@example.com');
  });
});

4. E2E Testing (Playwright)

4.1 Login Akışı

import { test, expect } from '@playwright/test';

test('user can login successfully', async ({ page }) => {
  await page.goto('/login');
  await page.fill('input[name="email"]', 'user@example.com');
  await page.fill('input[name="password"]', 'password123');
  await page.click('button[type="submit"]');

  await expect(page).toHaveURL('/dashboard');
  await expect(page.locator('h1')).toContainText('Hoş Geldiniz');
});

5. Visual Regression Testing

// Playwright visual test
test('dashboard visual comparison', async ({ page }) => {
  await page.goto('/dashboard');
  await expect(page).toHaveScreenshot('dashboard.png');
});

6. TDD (Test Driven Development)

  1. RED: Testi yaz ve başarısız olduğunu gör.
  2. GREEN: Testin geçmesi için gereken minimum kodu yaz.
  3. REFACTOR: Kodu ve testi temizle, standartlara uygun hale getir.

7. Test Yazım Kuralları

  • AAA Pattern: Arrange, Act, Assert.
  • Isolasyon: Testler birbirinden bağımsız olmalı.
  • Hız: Unit testler çok hızlı çalışmalı.
  • Readable: Test ismi neyi test ettiğini açıkça söylemeli.
  • Deterministic: Aynı girdiyle her zaman aynı sonuç.

🔄 Workflow

Kaynak: Spotify's Testing Pyramid & Playwright Best Practices

Aşama 1: Strategy & Test Plan

  • [ ] Define Coverage Scope: Kritik kullanıcı akışlarını ve test gerektiren logic'leri belirle.
  • [ ] Choose Level: Test piramidine göre (Unit -> Integration -> E2E) doğru test seviyesini seç.
  • [ ] Infrastructure Setup: Vitest/Jest veya Playwright ortamını yapılandır, gerekli mock'ları hazırla.

Aşama 2: Implementation & Interaction

  • [ ] Unit Tests: Fonksiyonları ve UI bileşenlerini izole (Stub/Mock kullanarak) test et.
  • [ ] Integration Flows: Servislerin ve veritabanı/API katmanının uyumunu doğrula.
  • [ ] E2E Scenarios: Playwright ile gerçek tarayıcı üzerinde "Login -> Checkout" gibi tam akışları simüle et.

Aşama 3: Verification & CI/CD

  • [ ] Coverage Audit: Test kapsamını (Line/Branch coverage) analiz et ve boşlukları doldur.
  • [ ] Visual Regressions: Arayüzdeki beklenmedik değişiklikleri "Snapshot Testing" ile yakala.
  • [ ] Automated Pipeline: Tüm testlerin CI/CD aşamasında (Check-in'den önce) çalıştığından emin ol.

Kontrol Noktaları

| Aşama | Doğrulama | |-------|-----------| | 1 | Testler "Flaky" (bazen geçen bazen kalan) özellikten arındırıldı mı? | | 2 | Mock veriler gerçek dünya senaryolarını (Edge cases) yansıtıyor mu? | | 3 | E2E testleri production ortamını birebir simüle ediyor mu? |


Testing v2.5 - With Workflow