@reasonabletech/config-playwright 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,689 @@
1
+ # config-playwright API Reference
2
+
3
+ ## Package Exports
4
+
5
+ ### Main Entry Point (`@reasonabletech/config-playwright`)
6
+
7
+ ```typescript
8
+ import {
9
+ createPlaywrightConfig,
10
+ createCIConfig,
11
+ createCrossAppConfig,
12
+ createBaseConfig,
13
+ baseConfig,
14
+ } from "@reasonabletech/config-playwright";
15
+
16
+ import type {
17
+ PlaywrightConfig,
18
+ DeepReadonly,
19
+ TestEnvironmentConfig,
20
+ TestEnvironmentServices,
21
+ } from "@reasonabletech/config-playwright";
22
+ ```
23
+
24
+ ### Base Entry Point (`@reasonabletech/config-playwright/base`)
25
+
26
+ ```typescript
27
+ import {
28
+ createBaseConfig,
29
+ createDesktopConfig,
30
+ createMobileConfig,
31
+ createChromiumConfig,
32
+ desktopConfig,
33
+ mobileConfig,
34
+ chromiumOnlyConfig,
35
+ } from "@reasonabletech/config-playwright/base";
36
+ ```
37
+
38
+ ### Cross-App Entry Point (`@reasonabletech/config-playwright/cross-app`)
39
+
40
+ ```typescript
41
+ import {
42
+ createCrossAppConfig,
43
+ createAccessibilityConfig,
44
+ createPerformanceConfig,
45
+ createAuthTestConfig,
46
+ createAuthWorkflowConfig,
47
+ crossAppConfig,
48
+ accessibilityConfig,
49
+ performanceConfig,
50
+ } from "@reasonabletech/config-playwright/cross-app";
51
+
52
+ import type {
53
+ CrossAppConfigOptions,
54
+ AuthWorkflowOptions,
55
+ AuthWorkflowConfig,
56
+ } from "@reasonabletech/config-playwright/cross-app";
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Main Factory Functions
62
+
63
+ ### `createPlaywrightConfig()`
64
+
65
+ Creates a merged Playwright configuration from the base config and custom options.
66
+
67
+ **Signature:**
68
+
69
+ ```typescript
70
+ function createPlaywrightConfig(
71
+ customConfig?: PlaywrightConfig
72
+ ): PlaywrightTestConfig;
73
+ ```
74
+
75
+ **Parameters:**
76
+
77
+ | Parameter | Type | Default | Description |
78
+ | -------------- | ------------------ | ------- | ------------------------- |
79
+ | `customConfig` | `PlaywrightConfig` | `{}` | Custom configuration |
80
+
81
+ **Returns:** `PlaywrightTestConfig`
82
+
83
+ ---
84
+
85
+ ### `createCIConfig()`
86
+
87
+ Creates a configuration optimized for CI/CD environments with parallel execution and artifact retention.
88
+
89
+ **Signature:**
90
+
91
+ ```typescript
92
+ function createCIConfig(
93
+ customConfig?: PlaywrightConfig
94
+ ): PlaywrightTestConfig;
95
+ ```
96
+
97
+ **CI-Specific Settings:**
98
+
99
+ | Setting | Value |
100
+ | ------------- | ---------------------- |
101
+ | `fullyParallel` | `true` |
102
+ | `retries` | `3` |
103
+ | `workers` | `4` |
104
+ | `trace` | `"retain-on-failure"` |
105
+ | `video` | `"retain-on-failure"` |
106
+ | `screenshot` | `"only-on-failure"` |
107
+
108
+ ---
109
+
110
+ ## Base Configuration Functions
111
+
112
+ ### `createBaseConfig()`
113
+
114
+ Creates a base configuration for single-app testing.
115
+
116
+ **Signature:**
117
+
118
+ ```typescript
119
+ function createBaseConfig(
120
+ customConfig?: PlaywrightConfig
121
+ ): PlaywrightTestConfig;
122
+ ```
123
+
124
+ **Includes:**
125
+
126
+ - All base config defaults
127
+ - `storageState: undefined` (no cross-app auth state)
128
+
129
+ ---
130
+
131
+ ### `createDesktopConfig()`
132
+
133
+ Creates a desktop-only configuration for faster testing cycles.
134
+
135
+ **Signature:**
136
+
137
+ ```typescript
138
+ function createDesktopConfig(
139
+ customConfig?: PlaywrightConfig
140
+ ): PlaywrightTestConfig;
141
+ ```
142
+
143
+ **Browser Projects:**
144
+
145
+ - `chromium` (Desktop Chrome)
146
+ - `firefox` (Desktop Firefox)
147
+ - `webkit` (Desktop Safari)
148
+
149
+ ---
150
+
151
+ ### `createMobileConfig()`
152
+
153
+ Creates a mobile-only configuration for mobile-specific testing.
154
+
155
+ **Signature:**
156
+
157
+ ```typescript
158
+ function createMobileConfig(
159
+ customConfig?: PlaywrightConfig
160
+ ): PlaywrightTestConfig;
161
+ ```
162
+
163
+ **Device Projects:**
164
+
165
+ - `Mobile Chrome` (Pixel 5)
166
+ - `Mobile Safari` (iPhone 12)
167
+
168
+ ---
169
+
170
+ ### `createChromiumConfig()`
171
+
172
+ Creates a Chromium-only configuration for fast development iteration.
173
+
174
+ **Signature:**
175
+
176
+ ```typescript
177
+ function createChromiumConfig(
178
+ customConfig?: PlaywrightConfig
179
+ ): PlaywrightTestConfig;
180
+ ```
181
+
182
+ **Settings:**
183
+
184
+ - Single Chromium browser
185
+ - `workers: 1` for consistent debugging
186
+
187
+ ---
188
+
189
+ ## Cross-App Functions
190
+
191
+ ### `createCrossAppConfig()`
192
+
193
+ Creates a Playwright configuration for testing workflows that span multiple applications.
194
+
195
+ **Signature:**
196
+
197
+ ```typescript
198
+ function createCrossAppConfig(
199
+ options: CrossAppConfigOptions
200
+ ): PlaywrightTestConfig;
201
+ ```
202
+
203
+ **Parameters:**
204
+
205
+ ```typescript
206
+ interface CrossAppConfigOptions {
207
+ environments: Record<string, TestEnvironmentConfig | undefined>;
208
+ customConfig?: PlaywrightConfig;
209
+ }
210
+
211
+ interface TestEnvironmentConfig {
212
+ baseUrls: Record<string, string>;
213
+ services: TestEnvironmentServices;
214
+ smokeTestsOnly?: boolean;
215
+ }
216
+
217
+ interface TestEnvironmentServices {
218
+ useRealServices: boolean;
219
+ mockExternalAPIs: boolean;
220
+ }
221
+ ```
222
+
223
+ **Environment Selection:** Uses `TEST_ENV` environment variable, defaults to `"development"`.
224
+
225
+ **Cross-App Specific Settings:**
226
+
227
+ | Setting | Value |
228
+ | ------------------- | ------------------------------------------- |
229
+ | `testDir` | `"./tests/acceptance/cross-app"` |
230
+ | `actionTimeout` | `10000` (10 seconds) |
231
+ | `navigationTimeout` | `15000` (15 seconds) |
232
+ | `video` | `"retain-on-failure"` |
233
+ | `trace` | `"retain-on-failure"` |
234
+ | `viewport` | `{ width: 1920, height: 1080 }` |
235
+
236
+ ---
237
+
238
+ ### `createAccessibilityConfig()`
239
+
240
+ Creates a configuration for accessibility testing with axe-core.
241
+
242
+ **Signature:**
243
+
244
+ ```typescript
245
+ function createAccessibilityConfig(
246
+ customConfig?: PlaywrightConfig
247
+ ): PlaywrightTestConfig;
248
+ ```
249
+
250
+ **Accessibility-Specific Settings:**
251
+
252
+ | Setting | Value |
253
+ | ------------------- | ------------------------------------ |
254
+ | `testDir` | `"./tests/acceptance/accessibility"` |
255
+ | `actionTimeout` | `15000` (15 seconds) |
256
+ | `navigationTimeout` | `20000` (20 seconds) |
257
+ | `viewport` | `{ width: 1280, height: 720 }` |
258
+
259
+ ---
260
+
261
+ ### `createPerformanceConfig()`
262
+
263
+ Creates a configuration for performance testing with Lighthouse integration.
264
+
265
+ **Signature:**
266
+
267
+ ```typescript
268
+ function createPerformanceConfig(
269
+ customConfig?: PlaywrightConfig
270
+ ): PlaywrightTestConfig;
271
+ ```
272
+
273
+ **Performance-Specific Settings:**
274
+
275
+ | Setting | Value |
276
+ | ------------------- | ------------------------------------ |
277
+ | `testDir` | `"./tests/acceptance/performance"` |
278
+ | `fullyParallel` | `false` (sequential for accuracy) |
279
+ | `workers` | `1` |
280
+ | `actionTimeout` | `30000` (30 seconds) |
281
+ | `navigationTimeout` | `45000` (45 seconds) |
282
+ | `video` | `"off"` |
283
+ | `screenshot` | `"off"` |
284
+ | `trace` | `"off"` |
285
+
286
+ ---
287
+
288
+ ### `createAuthTestConfig()`
289
+
290
+ Creates a configuration optimized for authentication workflow testing.
291
+
292
+ **Signature:**
293
+
294
+ ```typescript
295
+ function createAuthTestConfig(
296
+ options: CrossAppConfigOptions
297
+ ): PlaywrightTestConfig;
298
+ ```
299
+
300
+ **Auth Test Settings:**
301
+
302
+ - `testDir: "./tests/acceptance/auth"`
303
+ - `storageState: undefined` (starts unauthenticated)
304
+
305
+ ---
306
+
307
+ ### `createAuthWorkflowConfig()`
308
+
309
+ Creates a cross-domain authentication configuration object (not a Playwright config).
310
+
311
+ **Signature:**
312
+
313
+ ```typescript
314
+ function createAuthWorkflowConfig(
315
+ options: AuthWorkflowOptions
316
+ ): AuthWorkflowConfig;
317
+ ```
318
+
319
+ **Parameters:**
320
+
321
+ ```typescript
322
+ interface AuthWorkflowOptions {
323
+ domain: string; // Cookie domain (e.g., ".example.com")
324
+ expectedPersistence: readonly string[]; // Subdomains for persistence
325
+ }
326
+ ```
327
+
328
+ **Returns:**
329
+
330
+ ```typescript
331
+ interface AuthWorkflowConfig {
332
+ cookieConfig: {
333
+ domain: string;
334
+ secure: true;
335
+ httpOnly: true;
336
+ sameSite: "lax";
337
+ };
338
+ expectedPersistence: readonly string[];
339
+ }
340
+ ```
341
+
342
+ ---
343
+
344
+ ## Configuration Types
345
+
346
+ ### `PlaywrightConfig`
347
+
348
+ Immutable Playwright configuration type.
349
+
350
+ ```typescript
351
+ type PlaywrightConfig = DeepReadonly<PlaywrightTestConfig>;
352
+ ```
353
+
354
+ ### `DeepReadonly<T>`
355
+
356
+ Utility type for immutable configuration objects.
357
+
358
+ ```typescript
359
+ type DeepReadonly<T> = {
360
+ readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>
361
+ ? ReadonlyArray<DeepReadonly<U>>
362
+ : T[P] extends Array<infer U>
363
+ ? ReadonlyArray<DeepReadonly<U>>
364
+ : T[P] extends object
365
+ ? DeepReadonly<T[P]>
366
+ : T[P];
367
+ };
368
+ ```
369
+
370
+ ---
371
+
372
+ ## Preset Configurations
373
+
374
+ ### `baseConfig`
375
+
376
+ Base configuration applied to all test types.
377
+
378
+ ```typescript
379
+ const baseConfig: PlaywrightTestConfig = {
380
+ testDir: "./tests/acceptance",
381
+ testMatch: "**/*.{test,spec}.{ts,js}",
382
+ fullyParallel: true,
383
+ forbidOnly: Boolean(process.env.CI),
384
+ retries: process.env.CI ? 2 : 0,
385
+ workers: process.env.CI ? 4 : undefined,
386
+ timeout: 30000,
387
+ expect: { timeout: 5000 },
388
+ reporter: [
389
+ ["html", { outputFolder: "./generated/playwright/reports" }],
390
+ ["json", { outputFile: "./generated/playwright/results.json" }],
391
+ process.env.CI ? ["github"] : ["list"],
392
+ ],
393
+ outputDir: "./generated/playwright/test-results",
394
+ use: {
395
+ viewport: { width: 1280, height: 720 },
396
+ ignoreHTTPSErrors: true,
397
+ headless: true,
398
+ actionTimeout: 10000,
399
+ navigationTimeout: 30000,
400
+ trace: "on-first-retry",
401
+ video: "retain-on-failure",
402
+ screenshot: "only-on-failure",
403
+ storageState: undefined,
404
+ },
405
+ projects: [/* Dynamic based on CI */],
406
+ webServer: process.env.CI ? undefined : {
407
+ command: "pnpm dev",
408
+ reuseExistingServer: true,
409
+ timeout: 120000,
410
+ },
411
+ };
412
+ ```
413
+
414
+ ### `desktopConfig`
415
+
416
+ Desktop browser matrix.
417
+
418
+ ```typescript
419
+ const desktopConfig = {
420
+ projects: [
421
+ { name: "chromium", use: { ...devices["Desktop Chrome"] } },
422
+ { name: "firefox", use: { ...devices["Desktop Firefox"] } },
423
+ { name: "webkit", use: { ...devices["Desktop Safari"] } },
424
+ ],
425
+ };
426
+ ```
427
+
428
+ ### `mobileConfig`
429
+
430
+ Mobile device matrix.
431
+
432
+ ```typescript
433
+ const mobileConfig = {
434
+ projects: [
435
+ { name: "Mobile Chrome", use: { ...devices["Pixel 5"] } },
436
+ { name: "Mobile Safari", use: { ...devices["iPhone 12"] } },
437
+ ],
438
+ };
439
+ ```
440
+
441
+ ### `chromiumOnlyConfig`
442
+
443
+ Single-browser development config.
444
+
445
+ ```typescript
446
+ const chromiumOnlyConfig = {
447
+ projects: [
448
+ { name: "chromium", use: { ...devices["Desktop Chrome"] } },
449
+ ],
450
+ };
451
+ ```
452
+
453
+ ---
454
+
455
+ ## Default Options Reference
456
+
457
+ ### Base Configuration Defaults
458
+
459
+ | Option | Local Dev | CI |
460
+ | -------------------- | ------------------ | ----------------------- |
461
+ | `fullyParallel` | `true` | `true` |
462
+ | `retries` | `0` | `2` |
463
+ | `workers` | `undefined` (auto) | `4` |
464
+ | `forbidOnly` | `false` | `true` |
465
+ | `projects` | Chromium only | Full browser + devices |
466
+ | `webServer` | `pnpm dev` | `undefined` |
467
+ | `reporter` | `["list"]` | `["github"]` |
468
+
469
+ ### Timeout Defaults
470
+
471
+ | Timeout | Value |
472
+ | -------------------- | --------- |
473
+ | `timeout` (test) | 30 seconds |
474
+ | `expect.timeout` | 5 seconds |
475
+ | `actionTimeout` | 10 seconds |
476
+ | `navigationTimeout` | 30 seconds |
477
+ | `webServer.timeout` | 120 seconds |
478
+
479
+ ---
480
+
481
+ ## Usage Examples
482
+
483
+ ### Basic Single-App Testing
484
+
485
+ ```typescript
486
+ // playwright.config.ts
487
+ import { createPlaywrightConfig } from "@reasonabletech/config-playwright";
488
+
489
+ export default createPlaywrightConfig();
490
+ ```
491
+
492
+ ### Custom Base URL
493
+
494
+ ```typescript
495
+ // playwright.config.ts
496
+ import { createPlaywrightConfig } from "@reasonabletech/config-playwright";
497
+
498
+ export default createPlaywrightConfig({
499
+ use: {
500
+ baseURL: "http://localhost:3000",
501
+ },
502
+ });
503
+ ```
504
+
505
+ ### Desktop-Only Testing
506
+
507
+ ```typescript
508
+ // playwright.config.ts
509
+ import { createDesktopConfig } from "@reasonabletech/config-playwright/base";
510
+
511
+ export default createDesktopConfig({
512
+ use: {
513
+ baseURL: "http://localhost:3000",
514
+ },
515
+ });
516
+ ```
517
+
518
+ ### Mobile-Only Testing
519
+
520
+ ```typescript
521
+ // playwright.config.ts
522
+ import { createMobileConfig } from "@reasonabletech/config-playwright/base";
523
+
524
+ export default createMobileConfig({
525
+ use: {
526
+ baseURL: "http://localhost:3000",
527
+ },
528
+ });
529
+ ```
530
+
531
+ ### Fast Development Testing
532
+
533
+ ```typescript
534
+ // playwright.config.ts
535
+ import { createChromiumConfig } from "@reasonabletech/config-playwright/base";
536
+
537
+ export default createChromiumConfig({
538
+ use: {
539
+ baseURL: "http://localhost:3000",
540
+ },
541
+ });
542
+ ```
543
+
544
+ ### CI/CD Pipeline
545
+
546
+ ```typescript
547
+ // playwright.config.ts
548
+ import { createCIConfig } from "@reasonabletech/config-playwright";
549
+
550
+ export default createCIConfig({
551
+ use: {
552
+ baseURL: process.env.BASE_URL,
553
+ },
554
+ });
555
+ ```
556
+
557
+ ### Cross-App Workflow Testing
558
+
559
+ ```typescript
560
+ // playwright.config.ts
561
+ import { createCrossAppConfig } from "@reasonabletech/config-playwright/cross-app";
562
+
563
+ const environments = {
564
+ development: {
565
+ baseUrls: {
566
+ landing: "http://localhost:3000",
567
+ app: "http://localhost:3001",
568
+ admin: "http://localhost:3002",
569
+ },
570
+ services: {
571
+ useRealServices: false,
572
+ mockExternalAPIs: true,
573
+ },
574
+ },
575
+ staging: {
576
+ baseUrls: {
577
+ landing: "https://staging.example.com",
578
+ app: "https://app.staging.example.com",
579
+ admin: "https://admin.staging.example.com",
580
+ },
581
+ services: {
582
+ useRealServices: true,
583
+ mockExternalAPIs: false,
584
+ },
585
+ },
586
+ };
587
+
588
+ export default createCrossAppConfig({ environments });
589
+ ```
590
+
591
+ ### Accessibility Testing
592
+
593
+ ```typescript
594
+ // playwright.config.ts
595
+ import { createAccessibilityConfig } from "@reasonabletech/config-playwright/cross-app";
596
+
597
+ export default createAccessibilityConfig({
598
+ use: {
599
+ baseURL: "http://localhost:3000",
600
+ },
601
+ });
602
+ ```
603
+
604
+ ### Performance Testing
605
+
606
+ ```typescript
607
+ // playwright.config.ts
608
+ import { createPerformanceConfig } from "@reasonabletech/config-playwright/cross-app";
609
+
610
+ export default createPerformanceConfig({
611
+ use: {
612
+ baseURL: "http://localhost:3000",
613
+ },
614
+ });
615
+ ```
616
+
617
+ ### Authentication Flow Testing
618
+
619
+ ```typescript
620
+ // playwright.config.ts
621
+ import { createAuthTestConfig } from "@reasonabletech/config-playwright/cross-app";
622
+
623
+ const environments = {
624
+ development: {
625
+ baseUrls: {
626
+ auth: "http://localhost:4000",
627
+ app: "http://localhost:3000",
628
+ },
629
+ services: {
630
+ useRealServices: false,
631
+ mockExternalAPIs: true,
632
+ },
633
+ },
634
+ };
635
+
636
+ export default createAuthTestConfig({ environments });
637
+ ```
638
+
639
+ ### Cross-Domain Cookie Configuration
640
+
641
+ ```typescript
642
+ // tests/helpers/auth.ts
643
+ import { createAuthWorkflowConfig } from "@reasonabletech/config-playwright/cross-app";
644
+
645
+ export const authConfig = createAuthWorkflowConfig({
646
+ domain: ".example.com",
647
+ expectedPersistence: [
648
+ "accounts.example.com",
649
+ "app.example.com",
650
+ "admin.example.com",
651
+ ],
652
+ });
653
+
654
+ // Use in tests:
655
+ // expect(authConfig.cookieConfig.secure).toBe(true);
656
+ // await expect(page).toHaveURL(authConfig.expectedPersistence[1]);
657
+ ```
658
+
659
+ ### Custom Project Matrix
660
+
661
+ ```typescript
662
+ // playwright.config.ts
663
+ import { createPlaywrightConfig } from "@reasonabletech/config-playwright";
664
+ import { devices } from "@playwright/test";
665
+
666
+ export default createPlaywrightConfig({
667
+ projects: [
668
+ { name: "chrome", use: { ...devices["Desktop Chrome"] } },
669
+ { name: "edge", use: { ...devices["Desktop Edge"] } },
670
+ { name: "tablet", use: { ...devices["iPad Mini"] } },
671
+ ],
672
+ });
673
+ ```
674
+
675
+ ---
676
+
677
+ ## Environment Variables
678
+
679
+ | Variable | Effect |
680
+ | ----------- | ----------------------------------------------- |
681
+ | `CI` | Enables CI mode (retries, full browser matrix) |
682
+ | `TEST_ENV` | Selects environment for cross-app configs |
683
+
684
+ ---
685
+
686
+ ## Related Documentation
687
+
688
+ - [Usage Guide](../guides/usage-guide.md) — Setup and patterns
689
+ - [Package README](../../README.md) — Quick start
@@ -0,0 +1,47 @@
1
+ # Migration Guide
2
+
3
+ This guide documents breaking changes and how to migrate between major versions of @reasonabletech/config-playwright.
4
+
5
+ ## Current Version
6
+
7
+ The current major version is **0.x** (pre-1.0). The API is stabilizing but may have breaking changes before 1.0.
8
+
9
+ ## Future Migration Notes
10
+
11
+ _No breaking changes documented yet. This section will be updated when breaking changes are released._
12
+
13
+ ---
14
+
15
+ ## Migration Template
16
+
17
+ When documenting a breaking change, use this structure:
18
+
19
+ ### Migrating from X.x to Y.0
20
+
21
+ #### Breaking Changes
22
+
23
+ 1. **Change description** - Brief explanation of what changed
24
+
25
+ **Before:**
26
+ ```typescript
27
+ // Old usage
28
+ ```
29
+
30
+ **After:**
31
+ ```typescript
32
+ // New usage
33
+ ```
34
+
35
+ 2. **Another change** - Description
36
+
37
+ #### Deprecations
38
+
39
+ - `oldFunction()` is deprecated in favor of `newFunction()`
40
+
41
+ #### New Features
42
+
43
+ - Feature description
44
+
45
+ ---
46
+
47
+ _Last updated: [date]_