اختبار المتصفح الشامل بـ Playwright
E2E with Playwright
يفتح متصفحاً حقيقياً وينفذ مسار المستخدم ويتحقق من النتيجة على سطح المكتب والجوال.
الخطوات
ثبّت Playwright: npm init playwright@latest.
اكتب الاختبار بمحددات الأدوار.
شغّل npx playwright test.
راجع التقرير عند الفشل.
import { test, expect } from '@playwright/test'
test('add a book', async ({ page }) => {
await page.goto('/')
await page.getByRole('textbox', { name: 'اسم الكتاب' }).fill('كتاب')
await page.getByRole('button', { name: 'إضافة' }).click()
await expect(page.getByText('كتاب')).toBeVisible()
})اكتب اختبار Playwright للمسار: [..] على سطح المكتب وعرض 390 بكسل.
