🟩 I2 · expect(response).toBeOK() ve JSON assertion

I2 · expect(response).toBeOK() ve JSON: `expect(response).toBeOK()`, Playwright'ın 2xx status kontrolü için yazdığı bir KISAYOLDUR — H1'deki `.statusCode(200)`'ün TypeScript'e çe

`expect(response).toBeOK()`, Playwright'ın 2xx status kontrolü için yazdığı bir KISAYOLDUR — H1'deki `.statusCode(200)`'ün TypeScript'e çevirisi, ama tek bir kod yerine TÜM 2xx aralığını (200-299) kontrol eder. JSON gövdesini doğrulamak için ise `await response.json()` ile ayrıştırıp normal Playwright `expect(...)` assertion'larını (`toBe`, `toEqual`, `toContain`) kullanırsın — UI testlerinde `expect(locator).toBeVisible()` yazmanla AYNI `expect` API'sidir, sadece nesne bir DOM elementi değil bir veri parçasıdır. Peki bu neden önemli bir tutarlılık? Çünkü GRUP I'nin gücü (I3) API ve UI assertion'larını AYNI sözdizimiyle YAZDIRTMASINDA yatar — testerın zihninde "API modu" ile "UI modu" arasında geçiş yükü OLMAZ. **Derin Playwright assertion rehberi için → `/playwright` sayfasına bak.**

🎬 Aynı expect(), İki Farklı Nesne

expect(locator).toBeVisible()

expect(body.title).toBe(...)

Bir UI testinde `expect(locator).toBeVisible()` yazarsın — bir DOM elementini doğrularsın.

Bir API testinde `expect(body.title).toBe(...)` yazarsın — AYNI `expect` fonksiyonu, farklı bir nesne.

Ders — Zihinsel model AYNIDIR; sadece kontrol ettiğin şey (DOM mu, JSON mu) değişir. Bu, I3'teki hibrit testlerin TEMELİDİR.

Status ve Gövde Doğrulama Sırası

expect(response.ok()).toBeTruthy() veya toBeOK() ile 2xx aralığını doğrula.

await response.json() ile ham JSON'u bir JavaScript nesnesine çevir.

expect(body.alan).toBe(...)/toContain(...) ile içeriği kontrol et.

Bir Playwright API response'unu doğrulama sırasını diz.

Request'i gönder, response nesnesini al

response.ok()/toBeOK() ile status'u kontrol et