mini-qr/playwright.config.ts
Estee Tey 9150dd785e
Add Playwright E2E testing framework (#106)
# Add End-to-End Testing with Playwright

This PR adds comprehensive end-to-end testing capabilities using Playwright to ensure the application's core functionality works as expected.

## Key Changes:

- Implemented Playwright for automated browser testing
- Added test scripts for core functionality:
  - QR code creation and customization
  - QR code scanning from file uploads
  - Config saving and loading
  - Batch export functionality
  - Visual regression testing with snapshots

## Testing Details:

- Tests verify that:
  - QR codes can be created with various settings
  - Generated QR codes can be scanned correctly
  - Configuration can be saved and loaded
  - Batch export works with CSV files
  - UI elements behave correctly (disabled/enabled states)

## Development Notes:

- Added `test:e2e` npm script to run the tests
- Updated `.gitignore` to exclude Playwright test results
- Added detailed testing documentation to CONTRIBUTING.md
- Included test fixtures and baseline snapshots for visual regression testing

The tests provide a safety net for future development and help ensure the application remains stable as new features are added.
2025-04-05 21:55:39 +08:00

57 lines
1.6 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test'
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests/e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:5173',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
/* Capture screenshot only when a test fails. */
screenshot: 'only-on-failure'
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] }
}
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
],
/* Run your local dev server before starting the tests */
webServer: {
command: 'pnpm dev',
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe'
}
})