mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
Unit tests in tests/unit/ use vitest, not playwright. Added testIgnore to playwright config to skip the unit directory.
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test'
|
|
|
|
/**
|
|
* Playwright configuration for E2E testing
|
|
* @see https://playwright.dev/docs/test-configuration
|
|
*/
|
|
export default defineConfig({
|
|
testDir: './tests',
|
|
// Exclude vitest unit tests - they're run separately with vitest
|
|
testIgnore: ['**/unit/**'],
|
|
// 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,
|
|
// Parallel workers on CI, single thread locally
|
|
workers: process.env.CI ? 2 : undefined,
|
|
// Reporter to use
|
|
reporter: [
|
|
['html', { outputFolder: 'tests/reports/playwright-report' }],
|
|
['json', { outputFile: 'tests/reports/test-results.json' }],
|
|
['list'],
|
|
],
|
|
// Shared settings for all tests
|
|
use: {
|
|
// Base URL for the application
|
|
baseURL: 'http://localhost:3333',
|
|
// Collect trace when retrying the failed test
|
|
trace: 'on-first-retry',
|
|
// Take screenshot on failure
|
|
screenshot: 'only-on-failure',
|
|
// Video on failure
|
|
video: 'retain-on-failure',
|
|
},
|
|
|
|
// Configure projects for major browsers
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
launchOptions: {
|
|
args: [
|
|
'--disable-dev-shm-usage',
|
|
'--no-sandbox',
|
|
'--disable-setuid-sandbox',
|
|
],
|
|
},
|
|
},
|
|
},
|
|
{
|
|
name: 'firefox',
|
|
use: { ...devices['Desktop Firefox'] },
|
|
},
|
|
{
|
|
name: 'webkit',
|
|
use: { ...devices['Desktop Safari'] },
|
|
},
|
|
// Mobile viewports
|
|
{
|
|
name: 'Mobile Chrome',
|
|
use: { ...devices['Pixel 5'] },
|
|
},
|
|
{
|
|
name: 'Mobile Safari',
|
|
use: { ...devices['iPhone 12'] },
|
|
},
|
|
// Visual regression testing project
|
|
{
|
|
name: 'visual',
|
|
testMatch: /visual\/.*.spec.ts/,
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
// Consistent viewport for visual tests
|
|
viewport: { width: 1920, height: 1080 },
|
|
// Disable animations for visual tests
|
|
launchOptions: {
|
|
args: ['--force-prefers-reduced-motion'],
|
|
},
|
|
},
|
|
},
|
|
],
|
|
|
|
// Run local dev server before starting the tests
|
|
webServer: {
|
|
command: 'cd app && rm -rf .next && E2E_TEST=true pnpm dev',
|
|
port: 3333,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120 * 1000,
|
|
},
|
|
}) |