feat: Add Playwright end-to-end testing setup and initial test suites for various application flows.

This commit is contained in:
supalerk-ar66 2026-03-02 16:26:22 +07:00
parent 9bc24fbe8a
commit a3b2e55443
50 changed files with 3321 additions and 101 deletions

View file

@ -0,0 +1,57 @@
import { defineConfig, devices } from '@playwright/test';
/**
* @file playwright.config.ts
* @description Automated E2E Testing Playwright
*/
export default defineConfig({
// โฟลเดอร์ที่เก็บไฟล์เทส (ชี้ไปที่โฟลเดอร์ปลายทางที่เราสร้าง)
testDir: './tests/e2e',
// รันเทสแบบขนาน (พร้อมๆ กันหลายไฟล์) เพื่อให้เสร็จเร็วขึ้น
fullyParallel: true,
// หากการรันเทสบน CI/CD ล้มเหลว ให้ลองรันซ้ำ 2 ครั้ง
retries: process.env.CI ? 2 : 0,
// จำนวน Worker ที่ใช้รันเทส
workers: process.env.CI ? 1 : undefined,
// รูปแบบการแสดงผลลัพธ์ (Reporter)
reporter: 'html',
use: {
// กำหนดล่วงหน้าว่าเว็บที่เรากำลังจะพุ่งไปหาคือ URL อะไร (พอร์ต 3000 ของ Nuxt)
baseURL: 'http://localhost:3000',
// ตั้งค่าให้เก็บประวัติแบบติดตามผล (Trace) ถ้าระบบพัง จะได้กลับมาดูได้
trace: 'on-first-retry',
// ตั้งค่าเก็บรูปภาพหน้าจอเมื่อพัง (Screenshot on failure)
screenshot: 'only-on-failure'
},
// ตั้งค่าอุปกรณ์ที่ใช้ทดสอบ (Browsers)
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// หากต้องการเทสบน Firefox หรือ Safari สามารถเปิดคอมเมนต์บรรทัดถัดไปได้เลย
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
],
// (Optional) หากต้องการให้เปิด Local Server อัตโนมัติก่อนรันเทส สามารถเอาคอมเมนต์ออกได้
// webServer: {
// command: 'npm run dev',
// url: 'http://localhost:3000',
// reuseExistingServer: !process.env.CI,
// },
});