1- // File: playwright.config.ts
21/**
32 * Playwright Test Configuration for HRM Comprehensive Assessment
4- * Supports visual regression, mobile testing, and video recording
3+ * Optimized for performance and parallel execution
54 */
6- import { defineConfig , devices } from '@playwright/test'
7- import { getBaseURL } from './utils/urls'
5+ import { defineConfig , devices } from '@playwright/test' ;
6+ import { getBaseURL } from './utils/urls' ;
87
98// Check if Spotify/NextAuth credentials are available
109const hasSpotifyCredentials = ! ! (
1110 process . env . SPOTIFY_CLIENT_ID && process . env . SPOTIFY_CLIENT_SECRET
12- )
13- const hasNextAuthSecret = ! ! process . env . NEXTAUTH_SECRET
11+ ) ;
12+ const hasNextAuthSecret = ! ! process . env . NEXTAUTH_SECRET ;
1413
15- // Build ignore list based on available credentials
14+ // Optimized ignore list - run more tests by default
1615const testIgnoreList = [
17- ' integration-tests.spec.ts' ,
16+ // Only ignore truly integration-heavy tests for speed
1817 'comprehensive-assessment.spec.ts' ,
19- 'core-functionality.spec.ts' ,
20- 'mobile-essential.spec.ts' ,
2118 'mobile-assessment.spec.ts' ,
2219 'workflow-assessment.spec.ts' ,
2320 // OAuth tests are excluded from regular test runs (use separate npm script)
2421 'oauth/**/*.spec.ts' ,
25- ]
22+ ] ;
2623
2724// Only ignore auth-dependent tests if credentials are missing
2825if ( ! hasSpotifyCredentials ) {
29- testIgnoreList . push ( 'auth-flow.spec.ts' )
26+ testIgnoreList . push ( 'auth-flow.spec.ts' ) ;
3027}
3128if ( ! hasNextAuthSecret ) {
32- testIgnoreList . push ( 'debug.spec.ts' )
29+ testIgnoreList . push ( 'debug.spec.ts' ) ;
3330}
3431
3532export default defineConfig ( {
3633 testDir : './tests/playwright' ,
3734 testMatch : [ '**/*.spec.ts' ] ,
3835 testIgnore : testIgnoreList ,
3936
40- // Run tests in parallel
41- fullyParallel : false ,
37+ // Performance Optimizations
38+ fullyParallel : true ,
39+ workers : process . env . CI ? 2 : 1 , // Use 1 worker for visual tests to avoid race conditions
40+ timeout : 30000 , // Adjusted for potentially longer server startups
4241
4342 // Fail build on CI if you accidentally left test.only
4443 forbidOnly : ! ! process . env . CI ,
4544
4645 // Retry failed tests on CI
4746 retries : process . env . CI ? 2 : 0 ,
4847
49- // Use 1 worker for visual tests to avoid server race conditions
50- workers : 1 ,
51-
52- // Reporter configuration
53- reporter : [
54- [ 'html' , { outputFolder : 'playwright-report' } ] ,
55- [ 'json' , { outputFile : 'test-results/results.json' } ] ,
56- [ 'list' ] ,
57- ] ,
48+ // Test execution optimizations
49+ expect : {
50+ timeout : 5000 , // Faster assertion timeouts
51+ } ,
5852
5953 // Shared settings for all tests
6054 use : {
6155 // Base URL for all tests
6256 baseURL : getBaseURL ( ) ,
57+ actionTimeout : 0 ,
58+ headless : true ,
6359
6460 // Screenshot settings
6561 screenshot : {
@@ -80,26 +76,47 @@ export default defineConfig({
8076 viewport : { width : 1920 , height : 1080 } ,
8177 } ,
8278
83- // Single chromium project for fast testing
79+ // Browser configurations
8480 projects : [
8581 {
8682 name : 'chromium' ,
8783 use : {
8884 ...devices [ 'Desktop Chrome' ] ,
85+ launchOptions : {
86+ args : [
87+ '--disable-web-security' ,
88+ '--disable-features=TranslateUI' ,
89+ '--no-sandbox' ,
90+ '--disable-setuid-sandbox' ,
91+ '--disable-dev-shm-usage' ,
92+ ] ,
93+ } ,
8994 viewport : { width : 1920 , height : 1080 } ,
9095 video : {
9196 mode : 'retain-on-failure' ,
9297 size : { width : 1920 , height : 1080 } ,
9398 } ,
9499 } ,
95100 } ,
101+ // Mobile testing (optional, can be enabled via environment variable)
102+ ...( process . env . INCLUDE_MOBILE
103+ ? [
104+ {
105+ name : 'Mobile Chrome' ,
106+ use : { ...devices [ 'Pixel 5' ] } ,
107+ } ,
108+ ]
109+ : [ ] ) ,
96110 ] ,
97111
98- // Web server configuration disabled - start server manually
99- // webServer: {
100- // command: 'npm run dev',
101- // url: 'http://127.0.0.1:3000',
102- // reuseExistingServer: !process.env.CI,
103- // timeout: 120 * 1000,
104- // },
105- } )
112+
113+
114+ // Output configuration
115+ outputDir : 'test-results/' ,
116+ reporter : [
117+ [ 'list' ] ,
118+ [ 'html' , { outputFolder : 'playwright-report' , open : 'never' } ] ,
119+ [ 'json' , { outputFile : 'test-results/results.json' } ] ,
120+ ...( process . env . CI ? [ [ 'github' ] ] : [ ] ) ,
121+ ] ,
122+ } ) ;
0 commit comments