@reasonabletech/config-playwright 0.1.0 → 0.1.1
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.
- package/CHANGELOG.md +15 -0
- package/package.json +9 -6
- package/dist/base.js.map +0 -1
- package/dist/cross-app.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/src/base.d.ts.map +0 -1
- package/dist/src/cross-app.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/src/base.ts +0 -124
- package/src/cross-app.ts +0 -299
- package/src/index.ts +0 -207
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @reasonabletech/config-playwright
|
|
2
|
+
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- - Automated release.
|
|
8
|
+
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
Initial release preparation. See [README.md](./README.md) for usage.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
_Changelog entries are automatically generated from [changesets](https://github.com/changesets/changesets) on release._
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reasonabletech/config-playwright",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Shared Playwright configuration for E2E testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"reasonabletech",
|
|
@@ -29,8 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
|
+
"!dist/**/*.map",
|
|
33
|
+
"!dist/**/*.tsbuildinfo",
|
|
32
34
|
"docs/**/*",
|
|
33
|
-
"
|
|
35
|
+
"README.md",
|
|
36
|
+
"CHANGELOG.md"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"@axe-core/playwright": "^4.11.1",
|
|
@@ -45,10 +48,10 @@
|
|
|
45
48
|
"tsup": "8.5.1",
|
|
46
49
|
"typescript": "5.9.3",
|
|
47
50
|
"vitest": "4.0.18",
|
|
48
|
-
"@reasonabletech/config
|
|
49
|
-
"@reasonabletech/config-tsup": "0.1.
|
|
50
|
-
"@reasonabletech/config-typescript": "0.1.
|
|
51
|
-
"@reasonabletech/config-vitest": "0.1.
|
|
51
|
+
"@reasonabletech/eslint-config": "0.2.1",
|
|
52
|
+
"@reasonabletech/config-tsup": "0.1.2",
|
|
53
|
+
"@reasonabletech/config-typescript": "0.1.2",
|
|
54
|
+
"@reasonabletech/config-vitest": "0.1.1"
|
|
52
55
|
},
|
|
53
56
|
"peerDependencies": {
|
|
54
57
|
"@playwright/test": ">=1.58.2 <2",
|
package/dist/base.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/base.ts"],"names":["devices"],"mappings":";;;AA2DO,IAAM,UAAA,GAAmC;AAAA;AAAA,EAE9C,OAAA,EAAS,oBAAA;AAAA,EACT,SAAA,EAAW,0BAAA;AAAA;AAAA,EAGX,aAAA,EAAe,IAAA;AAAA,EACf,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA;AAAA,EAClC,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,EAAA,KAAO,SAAY,CAAA,GAAI,CAAA;AAAA,EAC5C,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,EAAA,KAAO,SAAY,CAAA,GAAI,MAAA;AAAA;AAAA,EAG5C,SAAS,EAAA,GAAK,GAAA;AAAA;AAAA,EACd,MAAA,EAAQ;AAAA,IACN,SAAS,CAAA,GAAI;AAAA;AAAA,GACf;AAAA;AAAA,EAGA,QAAA,EAAU;AAAA,IACR,CAAC,MAAA,EAAQ,EAAE,YAAA,EAAc,kCAAkC,CAAA;AAAA,IAC3D,CAAC,MAAA,EAAQ,EAAE,UAAA,EAAY,uCAA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A,IACR;AAAA,MACE,IAAA,EAAM,UAAA;AAAA,MACN,GAAA,EAAK,EAAE,GAAGA,OAAAA,CAAQ,gBAAgB,CAAA;AAAE;AACtC;AAEJ;AAOO,SAAS,gBAAA,CACd,eAAiC,YAAA,EACX;AACtB,EAAA,OAAO;AAAA,IACL,GAAG,UAAA;AAAA,IACH,GAAG,YAAA;AAAA,IACH,GAAA,EAAK;AAAA,MACH,GAAG,UAAA,CAAW,GAAA;AAAA,MACd,GAAG,YAAA,CAAa,GAAA;AAAA;AAAA,MAEhB,YAAA,EAAc;AAAA;AAAA,KAChB;AAAA,IACA,QAAA,EAAU,YAAA,CAAa,QAAA,IAAY,UAAA,CAAW;AAAA,GAChD;AACF;AAOO,SAAS,mBAAA,CACd,eAAiC,YAAA,EACX;AACtB,EAAA,OAAO,gBAAA,CAAiB;AAAA,IACtB,GAAG,YAAA;AAAA,IACH,UAAU,aAAA,CAAc;AAAA,GACzB,CAAA;AACH;AAOO,SAAS,kBAAA,CACd,eAAiC,YAAA,EACX;AACtB,EAAA,OAAO,gBAAA,CAAiB;AAAA,IACtB,GAAG,YAAA;AAAA,IACH,UAAU,YAAA,CAAa;AAAA,GACxB,CAAA;AACH;AAOO,SAAS,oBAAA,CACd,eAAiC,YAAA,EACX;AACtB,EAAA,OAAO,gBAAA,CAAiB;AAAA,IACtB,GAAG,YAAA;AAAA,IACH,UAAU,kBAAA,CAAmB,QAAA;AAAA,IAC7B,OAAA,EAAS;AAAA;AAAA,GACV,CAAA;AACH;AAEA,IAAO,YAAA,GAAQ","file":"base.js","sourcesContent":["/**\n * Base Playwright configuration for all applications\n * @module @reasonabletech/config-playwright\n */\n\nimport { type PlaywrightTestConfig, devices } from \"@playwright/test\";\n\n/**\n * Recursively makes all properties of `T` readonly.\n *\n * Useful for configuration objects defined with `as const`, ensuring callers\n * don't accidentally mutate shared config.\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends Array<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends object\n ? DeepReadonly<T[P]>\n : T[P];\n};\n\n/**\n * Immutable Playwright config type accepted by config helpers.\n */\nexport type PlaywrightConfig = DeepReadonly<PlaywrightTestConfig>;\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Service configuration for a test environment.\n */\nexport interface TestEnvironmentServices {\n /** Whether to use real backend services instead of mocks. */\n useRealServices: boolean;\n /** Whether to mock external (third-party) API calls. */\n mockExternalAPIs: boolean;\n}\n\n/**\n * Configuration for a single test environment (e.g. development, staging, production).\n *\n * Consumers define their own environment map and pass it to helpers like\n * {@link createCrossAppConfig} in `cross-app.ts`.\n */\nexport interface TestEnvironmentConfig {\n /** Map of application names to their base URLs. */\n baseUrls: Record<string, string>;\n /** Service-layer settings for this environment. */\n services: TestEnvironmentServices;\n /** When true, only smoke tests should run (e.g. in production). */\n smokeTestsOnly?: boolean;\n}\n\n/**\n * Base configuration options that apply to all acceptance test environments\n */\nexport const baseConfig: PlaywrightTestConfig = {\n // Test discovery and execution\n testDir: \"./tests/acceptance\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n // Global test settings\n fullyParallel: true,\n forbidOnly: Boolean(process.env.CI),\n retries: process.env.CI !== undefined ? 2 : 0,\n workers: process.env.CI !== undefined ? 4 : undefined,\n\n // Test execution timeouts\n timeout: 30 * 1000, // 30 seconds for individual tests\n expect: {\n timeout: 5 * 1000, // 5 seconds for assertions\n },\n\n // Reporter configuration for different environments\n reporter: [\n [\"html\", { outputFolder: \"./generated/playwright/reports\" }],\n [\"json\", { outputFile: \"./generated/playwright/results.json\" }],\n process.env.CI !== undefined ? [\"github\"] : [\"list\"],\n ],\n\n // Output folder for test results\n outputDir: \"./generated/playwright/test-results\",\n\n // Global test options\n use: {\n // Browser context settings\n viewport: { width: 1280, height: 720 },\n ignoreHTTPSErrors: true,\n headless: true, // Always headless by default (use --headed flag to override)\n\n // Action timeouts\n actionTimeout: 10 * 1000, // 10 seconds for actions\n navigationTimeout: 30 * 1000, // 30 seconds for navigation\n\n // Debugging and artifact collection - sensible defaults\n trace: \"on-first-retry\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n\n // No authentication state by default (apps can override)\n storageState: undefined,\n },\n\n // Browser and device matrix\n // Local dev: Chromium only for speed\n // CI: Full browser matrix for compatibility testing\n projects:\n process.env.CI !== undefined\n ? [\n // Desktop browsers\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n {\n name: \"firefox\",\n use: { ...devices[\"Desktop Firefox\"] },\n },\n {\n name: \"webkit\",\n use: { ...devices[\"Desktop Safari\"] },\n },\n\n // Mobile devices\n {\n name: \"Mobile Chrome\",\n use: { ...devices[\"Pixel 5\"] },\n },\n {\n name: \"Mobile Safari\",\n use: { ...devices[\"iPhone 12\"] },\n },\n\n // Tablet devices\n {\n name: \"iPad\",\n use: { ...devices[\"iPad Pro\"] },\n },\n ]\n : [\n // Local development: Chromium only for fast iteration\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n ],\n\n // Development server integration - common defaults for web apps\n webServer:\n process.env.CI !== undefined\n ? undefined\n : {\n command: \"pnpm dev\",\n reuseExistingServer: true,\n timeout: 120 * 1000, // 2 minutes to start\n },\n};\n\n/**\n * Creates a merged configuration from the base and any custom options\n * @param customConfig - Additional configuration options\n * @returns A merged Playwright configuration\n */\nexport function createPlaywrightConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...customConfig.use,\n },\n projects: customConfig.projects ?? baseConfig.projects,\n };\n}\n\n/**\n * Creates a configuration optimized for CI/CD environments\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration optimized for CI/CD\n */\nexport function createCIConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createPlaywrightConfig({\n ...customConfig,\n fullyParallel: true,\n retries: 3,\n workers: 4,\n use: {\n ...customConfig.use,\n trace: \"retain-on-failure\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n },\n });\n}\n\n// Re-export for convenience\nexport { createCrossAppConfig } from \"./cross-app.js\";\nexport { createBaseConfig } from \"./base.js\";\n\nexport default createPlaywrightConfig;\n","/**\n * Base browser configuration for Playwright testing\n * @module @reasonabletech/config-playwright/base\n */\n\nimport { type PlaywrightTestConfig, devices } from \"@playwright/test\";\nimport { baseConfig, type PlaywrightConfig } from \"./index.js\";\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Desktop-only browser configuration\n */\nexport const desktopConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n {\n name: \"firefox\",\n use: { ...devices[\"Desktop Firefox\"] },\n },\n {\n name: \"webkit\",\n use: { ...devices[\"Desktop Safari\"] },\n },\n ],\n};\n\n/**\n * Mobile-only browser configuration\n */\nexport const mobileConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"Mobile Chrome\",\n use: { ...devices[\"Pixel 5\"] },\n },\n {\n name: \"Mobile Safari\",\n use: { ...devices[\"iPhone 12\"] },\n },\n ],\n};\n\n/**\n * Chromium-only configuration for faster development testing\n */\nexport const chromiumOnlyConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n ],\n};\n\n/**\n * Creates a base Playwright configuration for single-app testing\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for standard single-app testing\n */\nexport function createBaseConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...customConfig.use,\n // Single-app specific settings\n storageState: undefined, // No cross-app auth state by default\n },\n projects: customConfig.projects ?? baseConfig.projects,\n };\n}\n\n/**\n * Creates a desktop-only configuration for faster testing cycles\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for desktop browsers only\n */\nexport function createDesktopConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: desktopConfig.projects,\n });\n}\n\n/**\n * Creates a mobile-only configuration for mobile-specific testing\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for mobile browsers only\n */\nexport function createMobileConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: mobileConfig.projects,\n });\n}\n\n/**\n * Creates a Chromium-only configuration for development\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for Chromium browser only\n */\nexport function createChromiumConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: chromiumOnlyConfig.projects,\n workers: 1, // Single worker for development\n });\n}\n\nexport default createBaseConfig;\n"]}
|
package/dist/cross-app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/cross-app.ts"],"names":[],"mappings":";;;AA2DO,IAAM,UAAA,GAAmC;AAAA;AAAA,EAE9C,OAAA,EAAS,oBAAA;AAAA,EACT,SAAA,EAAW,0BAAA;AAAA;AAAA,EAGX,aAAA,EAAe,IAAA;AAAA,EACf,UAAA,EAAY,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,EAAE,CAAA;AAAA,EAClC,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,EAAA,KAAO,SAAY,CAAA,GAAI,CAAA;AAAA,EAC5C,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,EAAA,KAAO,SAAY,CAAA,GAAI,MAAA;AAAA;AAAA,EAG5C,SAAS,EAAA,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AK;AAAA,QACH,GAAI,YAAA,CAAsC,GAAA;AAAA;AAAA,QAE1C,YAAA,EAAc;AAAA;AAChB;AACF,GACD,CAAA;AACH;AAEA,IAAO,iBAAA,GAAQ","file":"cross-app.js","sourcesContent":["/**\n * Base Playwright configuration for all applications\n * @module @reasonabletech/config-playwright\n */\n\nimport { type PlaywrightTestConfig, devices } from \"@playwright/test\";\n\n/**\n * Recursively makes all properties of `T` readonly.\n *\n * Useful for configuration objects defined with `as const`, ensuring callers\n * don't accidentally mutate shared config.\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends Array<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends object\n ? DeepReadonly<T[P]>\n : T[P];\n};\n\n/**\n * Immutable Playwright config type accepted by config helpers.\n */\nexport type PlaywrightConfig = DeepReadonly<PlaywrightTestConfig>;\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Service configuration for a test environment.\n */\nexport interface TestEnvironmentServices {\n /** Whether to use real backend services instead of mocks. */\n useRealServices: boolean;\n /** Whether to mock external (third-party) API calls. */\n mockExternalAPIs: boolean;\n}\n\n/**\n * Configuration for a single test environment (e.g. development, staging, production).\n *\n * Consumers define their own environment map and pass it to helpers like\n * {@link createCrossAppConfig} in `cross-app.ts`.\n */\nexport interface TestEnvironmentConfig {\n /** Map of application names to their base URLs. */\n baseUrls: Record<string, string>;\n /** Service-layer settings for this environment. */\n services: TestEnvironmentServices;\n /** When true, only smoke tests should run (e.g. in production). */\n smokeTestsOnly?: boolean;\n}\n\n/**\n * Base configuration options that apply to all acceptance test environments\n */\nexport const baseConfig: PlaywrightTestConfig = {\n // Test discovery and execution\n testDir: \"./tests/acceptance\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n // Global test settings\n fullyParallel: true,\n forbidOnly: Boolean(process.env.CI),\n retries: process.env.CI !== undefined ? 2 : 0,\n workers: process.env.CI !== undefined ? 4 : undefined,\n\n // Test execution timeouts\n timeout: 30 * 1000, // 30 seconds for individual tests\n expect: {\n timeout: 5 * 1000, // 5 seconds for assertions\n },\n\n // Reporter configuration for different environments\n reporter: [\n [\"html\", { outputFolder: \"./generated/playwright/reports\" }],\n [\"json\", { outputFile: \"./generated/playwright/results.json\" }],\n process.env.CI !== undefined ? [\"github\"] : [\"list\"],\n ],\n\n // Output folder for test results\n outputDir: \"./generated/playwright/test-results\",\n\n // Global test options\n use: {\n // Browser context settings\n viewport: { width: 1280, height: 720 },\n ignoreHTTPSErrors: true,\n headless: true, // Always headless by default (use --headed flag to override)\n\n // Action timeouts\n actionTimeout: 10 * 1000, // 10 seconds for actions\n navigationTimeout: 30 * 1000, // 30 seconds for navigation\n\n // Debugging and artifact collection - sensible defaults\n trace: \"on-first-retry\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n\n // No authentication state by default (apps can override)\n storageState: undefined,\n },\n\n // Browser and device matrix\n // Local dev: Chromium only for speed\n // CI: Full browser matrix for compatibility testing\n projects:\n process.env.CI !== undefined\n ? [\n // Desktop browsers\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n {\n name: \"firefox\",\n use: { ...devices[\"Desktop Firefox\"] },\n },\n {\n name: \"webkit\",\n use: { ...devices[\"Desktop Safari\"] },\n },\n\n // Mobile devices\n {\n name: \"Mobile Chrome\",\n use: { ...devices[\"Pixel 5\"] },\n },\n {\n name: \"Mobile Safari\",\n use: { ...devices[\"iPhone 12\"] },\n },\n\n // Tablet devices\n {\n name: \"iPad\",\n use: { ...devices[\"iPad Pro\"] },\n },\n ]\n : [\n // Local development: Chromium only for fast iteration\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n ],\n\n // Development server integration - common defaults for web apps\n webServer:\n process.env.CI !== undefined\n ? undefined\n : {\n command: \"pnpm dev\",\n reuseExistingServer: true,\n timeout: 120 * 1000, // 2 minutes to start\n },\n};\n\n/**\n * Creates a merged configuration from the base and any custom options\n * @param customConfig - Additional configuration options\n * @returns A merged Playwright configuration\n */\nexport function createPlaywrightConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...customConfig.use,\n },\n projects: customConfig.projects ?? baseConfig.projects,\n };\n}\n\n/**\n * Creates a configuration optimized for CI/CD environments\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration optimized for CI/CD\n */\nexport function createCIConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createPlaywrightConfig({\n ...customConfig,\n fullyParallel: true,\n retries: 3,\n workers: 4,\n use: {\n ...customConfig.use,\n trace: \"retain-on-failure\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n },\n });\n}\n\n// Re-export for convenience\nexport { createCrossAppConfig } from \"./cross-app.js\";\nexport { createBaseConfig } from \"./base.js\";\n\nexport default createPlaywrightConfig;\n","/**\n * Cross-app Playwright configuration for multi-frontend testing\n * @module @reasonabletech/config-playwright/cross-app\n */\n\nimport { type PlaywrightTestConfig } from \"@playwright/test\";\nimport {\n baseConfig,\n type PlaywrightConfig,\n type TestEnvironmentConfig,\n} from \"./index.js\";\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Cross-app specific configuration options\n */\nexport const crossAppConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/cross-app\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n use: {\n // Extended timeout for cross-app navigation\n actionTimeout: 10000,\n navigationTimeout: 15000,\n\n // Cross-domain configuration\n extraHTTPHeaders: {\n Accept: \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n },\n\n // Authentication state for cross-app flows\n storageState: \"tests/fixtures/auth/cross-app-authenticated.json\",\n\n // Enable video for complex cross-app debugging\n video: \"retain-on-failure\",\n trace: \"retain-on-failure\",\n },\n};\n\n/**\n * Accessibility testing configuration with axe-core\n */\nexport const accessibilityConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/accessibility\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n use: {\n // Slower execution for accessibility checks\n actionTimeout: 15000,\n navigationTimeout: 20000,\n },\n};\n\n/**\n * Performance testing configuration for Lighthouse integration\n */\nexport const performanceConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/performance\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n // Sequential execution for accurate performance measurements\n fullyParallel: false,\n workers: 1,\n\n use: {\n // Extended timeouts for performance measurements\n actionTimeout: 30000,\n navigationTimeout: 45000,\n\n // Minimal interference for accurate measurements\n video: \"off\",\n screenshot: \"off\",\n trace: \"off\",\n },\n};\n\n/**\n * Options for creating a cross-domain authentication workflow configuration.\n */\nexport interface AuthWorkflowOptions {\n /** The cookie domain (e.g. \".example.com\"). */\n domain: string;\n /**\n * List of subdomains where authentication cookies should persist\n * (e.g. [\"accounts.example.com\", \"app.example.com\"]).\n */\n expectedPersistence: readonly string[];\n}\n\n/**\n * Configuration shape returned by {@link createAuthWorkflowConfig}.\n */\nexport interface AuthWorkflowConfig {\n /**\n * Cookie settings used for cross-domain authentication.\n */\n readonly cookieConfig: {\n readonly domain: string;\n readonly secure: true;\n readonly httpOnly: true;\n readonly sameSite: \"lax\";\n };\n /**\n * Subdomains where authentication should remain valid.\n */\n readonly expectedPersistence: readonly string[];\n}\n\n/**\n * Creates a cross-domain authentication configuration for the given domain.\n * @param options - Domain and persistence settings\n * @returns An authentication workflow config object\n */\nexport function createAuthWorkflowConfig(\n options: AuthWorkflowOptions,\n): AuthWorkflowConfig {\n return {\n cookieConfig: {\n domain: options.domain,\n secure: true,\n httpOnly: true,\n sameSite: \"lax\" as const,\n },\n expectedPersistence: options.expectedPersistence,\n } as const;\n}\n\n/**\n * Options for creating a cross-app Playwright configuration.\n */\nexport interface CrossAppConfigOptions {\n /**\n * Map of environment names to their configuration.\n * The key used is determined by the `TEST_ENV` environment variable,\n * falling back to `\"development\"`.\n */\n environments: Readonly<Record<string, TestEnvironmentConfig | undefined>>;\n /** Additional Playwright configuration overrides. */\n customConfig?: PlaywrightConfig;\n}\n\n/**\n * Creates a Playwright configuration for cross-app workflows.\n *\n * Consumers must supply their own environment map so that base URLs are not\n * hardcoded in this shared package.\n * @param options - Environments map and optional custom config overrides\n * @returns A Playwright configuration optimized for cross-app testing\n */\nexport function createCrossAppConfig(\n options: CrossAppConfigOptions,\n): PlaywrightTestConfig {\n const { environments, customConfig = EMPTY_CONFIG } = options;\n\n const environment = process.env.TEST_ENV ?? \"development\";\n const envConfig = environments[environment];\n\n if (envConfig === undefined) {\n throw new Error(\n `Unknown test environment \"${environment}\". Available environments: ${Object.keys(environments).join(\", \")}`,\n );\n }\n\n const defaultBaseUrl = Object.values(envConfig.baseUrls).at(0);\n\n if (defaultBaseUrl === undefined) {\n throw new Error(\n `Environment \"${environment}\" must define at least one base URL`,\n );\n }\n\n return {\n ...baseConfig,\n ...crossAppConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...crossAppConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n // Set base URL to the first entry in baseUrls (typically the landing page)\n baseURL: defaultBaseUrl,\n },\n projects: [\n // Desktop browsers for cross-app flows\n {\n name: \"cross-app-chromium\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n // Cross-app specific browser settings\n viewport: { width: 1920, height: 1080 },\n },\n },\n {\n name: \"cross-app-firefox\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[1]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n {\n name: \"cross-app-webkit\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[2]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration for accessibility testing with axe-core\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration with accessibility testing setup\n */\nexport function createAccessibilityConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...accessibilityConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...accessibilityConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n },\n projects: [\n {\n name: \"accessibility-chromium\",\n testDir: \"./tests/acceptance/accessibility\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n viewport: { width: 1280, height: 720 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration for performance testing with Lighthouse\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration with performance testing setup\n */\nexport function createPerformanceConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...performanceConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...performanceConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n },\n projects: [\n {\n name: \"performance-chromium\",\n testDir: \"./tests/acceptance/performance\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration optimized for authentication workflow testing\n * @param options - Cross-app config options (environments map and optional custom config)\n * @returns A Playwright configuration for auth workflow testing\n */\nexport function createAuthTestConfig(\n options: CrossAppConfigOptions,\n): PlaywrightTestConfig {\n const { environments, customConfig = EMPTY_CONFIG } = options;\n return createCrossAppConfig({\n environments,\n customConfig: {\n ...customConfig,\n testDir: \"./tests/acceptance/auth\",\n use: {\n ...(customConfig as PlaywrightTestConfig).use,\n // No pre-authenticated state for auth tests\n storageState: undefined,\n },\n },\n });\n}\n\nexport default createCrossAppConfig;\n"]}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
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T,OAAA,EAAS,CAAA;AAAA,IACT,GAAA,EAAK;AAAA,MACH,GAAG,YAAA,CAAa,GAAA;AAAA,MAChB,KAAA,EAAO,mBAAA;AAAA,MACP,KAAA,EAAO,mBAAA;AAAA,MACP,UAAA,EAAY;AAAA;AACd,GACD,CAAA;AACH;AAMA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["/**\n * Cross-app Playwright configuration for multi-frontend testing\n * @module @reasonabletech/config-playwright/cross-app\n */\n\nimport { type PlaywrightTestConfig } from \"@playwright/test\";\nimport {\n baseConfig,\n type PlaywrightConfig,\n type TestEnvironmentConfig,\n} from \"./index.js\";\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Cross-app specific configuration options\n */\nexport const crossAppConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/cross-app\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n use: {\n // Extended timeout for cross-app navigation\n actionTimeout: 10000,\n navigationTimeout: 15000,\n\n // Cross-domain configuration\n extraHTTPHeaders: {\n Accept: \"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\",\n },\n\n // Authentication state for cross-app flows\n storageState: \"tests/fixtures/auth/cross-app-authenticated.json\",\n\n // Enable video for complex cross-app debugging\n video: \"retain-on-failure\",\n trace: \"retain-on-failure\",\n },\n};\n\n/**\n * Accessibility testing configuration with axe-core\n */\nexport const accessibilityConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/accessibility\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n use: {\n // Slower execution for accessibility checks\n actionTimeout: 15000,\n navigationTimeout: 20000,\n },\n};\n\n/**\n * Performance testing configuration for Lighthouse integration\n */\nexport const performanceConfig: PlaywrightTestConfig = {\n testDir: \"./tests/acceptance/performance\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n // Sequential execution for accurate performance measurements\n fullyParallel: false,\n workers: 1,\n\n use: {\n // Extended timeouts for performance measurements\n actionTimeout: 30000,\n navigationTimeout: 45000,\n\n // Minimal interference for accurate measurements\n video: \"off\",\n screenshot: \"off\",\n trace: \"off\",\n },\n};\n\n/**\n * Options for creating a cross-domain authentication workflow configuration.\n */\nexport interface AuthWorkflowOptions {\n /** The cookie domain (e.g. \".example.com\"). */\n domain: string;\n /**\n * List of subdomains where authentication cookies should persist\n * (e.g. [\"accounts.example.com\", \"app.example.com\"]).\n */\n expectedPersistence: readonly string[];\n}\n\n/**\n * Configuration shape returned by {@link createAuthWorkflowConfig}.\n */\nexport interface AuthWorkflowConfig {\n /**\n * Cookie settings used for cross-domain authentication.\n */\n readonly cookieConfig: {\n readonly domain: string;\n readonly secure: true;\n readonly httpOnly: true;\n readonly sameSite: \"lax\";\n };\n /**\n * Subdomains where authentication should remain valid.\n */\n readonly expectedPersistence: readonly string[];\n}\n\n/**\n * Creates a cross-domain authentication configuration for the given domain.\n * @param options - Domain and persistence settings\n * @returns An authentication workflow config object\n */\nexport function createAuthWorkflowConfig(\n options: AuthWorkflowOptions,\n): AuthWorkflowConfig {\n return {\n cookieConfig: {\n domain: options.domain,\n secure: true,\n httpOnly: true,\n sameSite: \"lax\" as const,\n },\n expectedPersistence: options.expectedPersistence,\n } as const;\n}\n\n/**\n * Options for creating a cross-app Playwright configuration.\n */\nexport interface CrossAppConfigOptions {\n /**\n * Map of environment names to their configuration.\n * The key used is determined by the `TEST_ENV` environment variable,\n * falling back to `\"development\"`.\n */\n environments: Readonly<Record<string, TestEnvironmentConfig | undefined>>;\n /** Additional Playwright configuration overrides. */\n customConfig?: PlaywrightConfig;\n}\n\n/**\n * Creates a Playwright configuration for cross-app workflows.\n *\n * Consumers must supply their own environment map so that base URLs are not\n * hardcoded in this shared package.\n * @param options - Environments map and optional custom config overrides\n * @returns A Playwright configuration optimized for cross-app testing\n */\nexport function createCrossAppConfig(\n options: CrossAppConfigOptions,\n): PlaywrightTestConfig {\n const { environments, customConfig = EMPTY_CONFIG } = options;\n\n const environment = process.env.TEST_ENV ?? \"development\";\n const envConfig = environments[environment];\n\n if (envConfig === undefined) {\n throw new Error(\n `Unknown test environment \"${environment}\". Available environments: ${Object.keys(environments).join(\", \")}`,\n );\n }\n\n const defaultBaseUrl = Object.values(envConfig.baseUrls).at(0);\n\n if (defaultBaseUrl === undefined) {\n throw new Error(\n `Environment \"${environment}\" must define at least one base URL`,\n );\n }\n\n return {\n ...baseConfig,\n ...crossAppConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...crossAppConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n // Set base URL to the first entry in baseUrls (typically the landing page)\n baseURL: defaultBaseUrl,\n },\n projects: [\n // Desktop browsers for cross-app flows\n {\n name: \"cross-app-chromium\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n // Cross-app specific browser settings\n viewport: { width: 1920, height: 1080 },\n },\n },\n {\n name: \"cross-app-firefox\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[1]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n {\n name: \"cross-app-webkit\",\n testDir: \"./tests/acceptance/cross-app\",\n use: {\n ...baseConfig.projects?.[2]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration for accessibility testing with axe-core\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration with accessibility testing setup\n */\nexport function createAccessibilityConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...accessibilityConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...accessibilityConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n },\n projects: [\n {\n name: \"accessibility-chromium\",\n testDir: \"./tests/acceptance/accessibility\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n viewport: { width: 1280, height: 720 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration for performance testing with Lighthouse\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration with performance testing setup\n */\nexport function createPerformanceConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...performanceConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...performanceConfig.use,\n ...(customConfig as PlaywrightTestConfig).use,\n },\n projects: [\n {\n name: \"performance-chromium\",\n testDir: \"./tests/acceptance/performance\",\n use: {\n ...baseConfig.projects?.[0]?.use,\n viewport: { width: 1920, height: 1080 },\n },\n },\n ],\n };\n}\n\n/**\n * Creates a configuration optimized for authentication workflow testing\n * @param options - Cross-app config options (environments map and optional custom config)\n * @returns A Playwright configuration for auth workflow testing\n */\nexport function createAuthTestConfig(\n options: CrossAppConfigOptions,\n): PlaywrightTestConfig {\n const { environments, customConfig = EMPTY_CONFIG } = options;\n return createCrossAppConfig({\n environments,\n customConfig: {\n ...customConfig,\n testDir: \"./tests/acceptance/auth\",\n use: {\n ...(customConfig as PlaywrightTestConfig).use,\n // No pre-authenticated state for auth tests\n storageState: undefined,\n },\n },\n });\n}\n\nexport default createCrossAppConfig;\n","/**\n * Base browser configuration for Playwright testing\n * @module @reasonabletech/config-playwright/base\n */\n\nimport { type PlaywrightTestConfig, devices } from \"@playwright/test\";\nimport { baseConfig, type PlaywrightConfig } from \"./index.js\";\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Desktop-only browser configuration\n */\nexport const desktopConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n {\n name: \"firefox\",\n use: { ...devices[\"Desktop Firefox\"] },\n },\n {\n name: \"webkit\",\n use: { ...devices[\"Desktop Safari\"] },\n },\n ],\n};\n\n/**\n * Mobile-only browser configuration\n */\nexport const mobileConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"Mobile Chrome\",\n use: { ...devices[\"Pixel 5\"] },\n },\n {\n name: \"Mobile Safari\",\n use: { ...devices[\"iPhone 12\"] },\n },\n ],\n};\n\n/**\n * Chromium-only configuration for faster development testing\n */\nexport const chromiumOnlyConfig: PlaywrightTestConfig = {\n projects: [\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n ],\n};\n\n/**\n * Creates a base Playwright configuration for single-app testing\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for standard single-app testing\n */\nexport function createBaseConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...customConfig.use,\n // Single-app specific settings\n storageState: undefined, // No cross-app auth state by default\n },\n projects: customConfig.projects ?? baseConfig.projects,\n };\n}\n\n/**\n * Creates a desktop-only configuration for faster testing cycles\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for desktop browsers only\n */\nexport function createDesktopConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: desktopConfig.projects,\n });\n}\n\n/**\n * Creates a mobile-only configuration for mobile-specific testing\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for mobile browsers only\n */\nexport function createMobileConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: mobileConfig.projects,\n });\n}\n\n/**\n * Creates a Chromium-only configuration for development\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration for Chromium browser only\n */\nexport function createChromiumConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createBaseConfig({\n ...customConfig,\n projects: chromiumOnlyConfig.projects,\n workers: 1, // Single worker for development\n });\n}\n\nexport default createBaseConfig;\n","/**\n * Base Playwright configuration for all applications\n * @module @reasonabletech/config-playwright\n */\n\nimport { type PlaywrightTestConfig, devices } from \"@playwright/test\";\n\n/**\n * Recursively makes all properties of `T` readonly.\n *\n * Useful for configuration objects defined with `as const`, ensuring callers\n * don't accidentally mutate shared config.\n */\nexport type DeepReadonly<T> = {\n readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends Array<infer U>\n ? ReadonlyArray<DeepReadonly<U>>\n : T[P] extends object\n ? DeepReadonly<T[P]>\n : T[P];\n};\n\n/**\n * Immutable Playwright config type accepted by config helpers.\n */\nexport type PlaywrightConfig = DeepReadonly<PlaywrightTestConfig>;\n\n// Empty readonly config for default parameters\nconst EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;\n\n/**\n * Service configuration for a test environment.\n */\nexport interface TestEnvironmentServices {\n /** Whether to use real backend services instead of mocks. */\n useRealServices: boolean;\n /** Whether to mock external (third-party) API calls. */\n mockExternalAPIs: boolean;\n}\n\n/**\n * Configuration for a single test environment (e.g. development, staging, production).\n *\n * Consumers define their own environment map and pass it to helpers like\n * {@link createCrossAppConfig} in `cross-app.ts`.\n */\nexport interface TestEnvironmentConfig {\n /** Map of application names to their base URLs. */\n baseUrls: Record<string, string>;\n /** Service-layer settings for this environment. */\n services: TestEnvironmentServices;\n /** When true, only smoke tests should run (e.g. in production). */\n smokeTestsOnly?: boolean;\n}\n\n/**\n * Base configuration options that apply to all acceptance test environments\n */\nexport const baseConfig: PlaywrightTestConfig = {\n // Test discovery and execution\n testDir: \"./tests/acceptance\",\n testMatch: \"**/*.{test,spec}.{ts,js}\",\n\n // Global test settings\n fullyParallel: true,\n forbidOnly: Boolean(process.env.CI),\n retries: process.env.CI !== undefined ? 2 : 0,\n workers: process.env.CI !== undefined ? 4 : undefined,\n\n // Test execution timeouts\n timeout: 30 * 1000, // 30 seconds for individual tests\n expect: {\n timeout: 5 * 1000, // 5 seconds for assertions\n },\n\n // Reporter configuration for different environments\n reporter: [\n [\"html\", { outputFolder: \"./generated/playwright/reports\" }],\n [\"json\", { outputFile: \"./generated/playwright/results.json\" }],\n process.env.CI !== undefined ? [\"github\"] : [\"list\"],\n ],\n\n // Output folder for test results\n outputDir: \"./generated/playwright/test-results\",\n\n // Global test options\n use: {\n // Browser context settings\n viewport: { width: 1280, height: 720 },\n ignoreHTTPSErrors: true,\n headless: true, // Always headless by default (use --headed flag to override)\n\n // Action timeouts\n actionTimeout: 10 * 1000, // 10 seconds for actions\n navigationTimeout: 30 * 1000, // 30 seconds for navigation\n\n // Debugging and artifact collection - sensible defaults\n trace: \"on-first-retry\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n\n // No authentication state by default (apps can override)\n storageState: undefined,\n },\n\n // Browser and device matrix\n // Local dev: Chromium only for speed\n // CI: Full browser matrix for compatibility testing\n projects:\n process.env.CI !== undefined\n ? [\n // Desktop browsers\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n {\n name: \"firefox\",\n use: { ...devices[\"Desktop Firefox\"] },\n },\n {\n name: \"webkit\",\n use: { ...devices[\"Desktop Safari\"] },\n },\n\n // Mobile devices\n {\n name: \"Mobile Chrome\",\n use: { ...devices[\"Pixel 5\"] },\n },\n {\n name: \"Mobile Safari\",\n use: { ...devices[\"iPhone 12\"] },\n },\n\n // Tablet devices\n {\n name: \"iPad\",\n use: { ...devices[\"iPad Pro\"] },\n },\n ]\n : [\n // Local development: Chromium only for fast iteration\n {\n name: \"chromium\",\n use: { ...devices[\"Desktop Chrome\"] },\n },\n ],\n\n // Development server integration - common defaults for web apps\n webServer:\n process.env.CI !== undefined\n ? undefined\n : {\n command: \"pnpm dev\",\n reuseExistingServer: true,\n timeout: 120 * 1000, // 2 minutes to start\n },\n};\n\n/**\n * Creates a merged configuration from the base and any custom options\n * @param customConfig - Additional configuration options\n * @returns A merged Playwright configuration\n */\nexport function createPlaywrightConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return {\n ...baseConfig,\n ...customConfig,\n use: {\n ...baseConfig.use,\n ...customConfig.use,\n },\n projects: customConfig.projects ?? baseConfig.projects,\n };\n}\n\n/**\n * Creates a configuration optimized for CI/CD environments\n * @param customConfig - Additional configuration options\n * @returns A Playwright configuration optimized for CI/CD\n */\nexport function createCIConfig(\n customConfig: PlaywrightConfig = EMPTY_CONFIG,\n): PlaywrightTestConfig {\n return createPlaywrightConfig({\n ...customConfig,\n fullyParallel: true,\n retries: 3,\n workers: 4,\n use: {\n ...customConfig.use,\n trace: \"retain-on-failure\",\n video: \"retain-on-failure\",\n screenshot: \"only-on-failure\",\n },\n });\n}\n\n// Re-export for convenience\nexport { createCrossAppConfig } from \"./cross-app.js\";\nexport { createBaseConfig } from \"./base.js\";\n\nexport default createPlaywrightConfig;\n"]}
|
package/dist/src/base.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,oBAAoB,EAAW,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,oBAe3B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,oBAW1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,oBAOhC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAYtB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAKtB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAKtB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAMtB;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BAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,mDAAmD;IACnD,QAAQ,EAAE,uBAAuB,CAAC;IAClC,mEAAmE;IACnE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,oBAoGxB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAUtB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,YAAY,GAAE,gBAA+B,GAC5C,oBAAoB,CAatB;AAGD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,eAAe,sBAAsB,CAAC"}
|
package/src/base.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base browser configuration for Playwright testing
|
|
3
|
-
* @module @reasonabletech/config-playwright/base
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { type PlaywrightTestConfig, devices } from "@playwright/test";
|
|
7
|
-
import { baseConfig, type PlaywrightConfig } from "./index.js";
|
|
8
|
-
|
|
9
|
-
// Empty readonly config for default parameters
|
|
10
|
-
const EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Desktop-only browser configuration
|
|
14
|
-
*/
|
|
15
|
-
export const desktopConfig: PlaywrightTestConfig = {
|
|
16
|
-
projects: [
|
|
17
|
-
{
|
|
18
|
-
name: "chromium",
|
|
19
|
-
use: { ...devices["Desktop Chrome"] },
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: "firefox",
|
|
23
|
-
use: { ...devices["Desktop Firefox"] },
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "webkit",
|
|
27
|
-
use: { ...devices["Desktop Safari"] },
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Mobile-only browser configuration
|
|
34
|
-
*/
|
|
35
|
-
export const mobileConfig: PlaywrightTestConfig = {
|
|
36
|
-
projects: [
|
|
37
|
-
{
|
|
38
|
-
name: "Mobile Chrome",
|
|
39
|
-
use: { ...devices["Pixel 5"] },
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "Mobile Safari",
|
|
43
|
-
use: { ...devices["iPhone 12"] },
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Chromium-only configuration for faster development testing
|
|
50
|
-
*/
|
|
51
|
-
export const chromiumOnlyConfig: PlaywrightTestConfig = {
|
|
52
|
-
projects: [
|
|
53
|
-
{
|
|
54
|
-
name: "chromium",
|
|
55
|
-
use: { ...devices["Desktop Chrome"] },
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Creates a base Playwright configuration for single-app testing
|
|
62
|
-
* @param customConfig - Additional configuration options
|
|
63
|
-
* @returns A Playwright configuration for standard single-app testing
|
|
64
|
-
*/
|
|
65
|
-
export function createBaseConfig(
|
|
66
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
67
|
-
): PlaywrightTestConfig {
|
|
68
|
-
return {
|
|
69
|
-
...baseConfig,
|
|
70
|
-
...customConfig,
|
|
71
|
-
use: {
|
|
72
|
-
...baseConfig.use,
|
|
73
|
-
...customConfig.use,
|
|
74
|
-
// Single-app specific settings
|
|
75
|
-
storageState: undefined, // No cross-app auth state by default
|
|
76
|
-
},
|
|
77
|
-
projects: customConfig.projects ?? baseConfig.projects,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Creates a desktop-only configuration for faster testing cycles
|
|
83
|
-
* @param customConfig - Additional configuration options
|
|
84
|
-
* @returns A Playwright configuration for desktop browsers only
|
|
85
|
-
*/
|
|
86
|
-
export function createDesktopConfig(
|
|
87
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
88
|
-
): PlaywrightTestConfig {
|
|
89
|
-
return createBaseConfig({
|
|
90
|
-
...customConfig,
|
|
91
|
-
projects: desktopConfig.projects,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Creates a mobile-only configuration for mobile-specific testing
|
|
97
|
-
* @param customConfig - Additional configuration options
|
|
98
|
-
* @returns A Playwright configuration for mobile browsers only
|
|
99
|
-
*/
|
|
100
|
-
export function createMobileConfig(
|
|
101
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
102
|
-
): PlaywrightTestConfig {
|
|
103
|
-
return createBaseConfig({
|
|
104
|
-
...customConfig,
|
|
105
|
-
projects: mobileConfig.projects,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Creates a Chromium-only configuration for development
|
|
111
|
-
* @param customConfig - Additional configuration options
|
|
112
|
-
* @returns A Playwright configuration for Chromium browser only
|
|
113
|
-
*/
|
|
114
|
-
export function createChromiumConfig(
|
|
115
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
116
|
-
): PlaywrightTestConfig {
|
|
117
|
-
return createBaseConfig({
|
|
118
|
-
...customConfig,
|
|
119
|
-
projects: chromiumOnlyConfig.projects,
|
|
120
|
-
workers: 1, // Single worker for development
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export default createBaseConfig;
|
package/src/cross-app.ts
DELETED
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-app Playwright configuration for multi-frontend testing
|
|
3
|
-
* @module @reasonabletech/config-playwright/cross-app
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { type PlaywrightTestConfig } from "@playwright/test";
|
|
7
|
-
import {
|
|
8
|
-
baseConfig,
|
|
9
|
-
type PlaywrightConfig,
|
|
10
|
-
type TestEnvironmentConfig,
|
|
11
|
-
} from "./index.js";
|
|
12
|
-
|
|
13
|
-
// Empty readonly config for default parameters
|
|
14
|
-
const EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Cross-app specific configuration options
|
|
18
|
-
*/
|
|
19
|
-
export const crossAppConfig: PlaywrightTestConfig = {
|
|
20
|
-
testDir: "./tests/acceptance/cross-app",
|
|
21
|
-
testMatch: "**/*.{test,spec}.{ts,js}",
|
|
22
|
-
|
|
23
|
-
use: {
|
|
24
|
-
// Extended timeout for cross-app navigation
|
|
25
|
-
actionTimeout: 10000,
|
|
26
|
-
navigationTimeout: 15000,
|
|
27
|
-
|
|
28
|
-
// Cross-domain configuration
|
|
29
|
-
extraHTTPHeaders: {
|
|
30
|
-
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// Authentication state for cross-app flows
|
|
34
|
-
storageState: "tests/fixtures/auth/cross-app-authenticated.json",
|
|
35
|
-
|
|
36
|
-
// Enable video for complex cross-app debugging
|
|
37
|
-
video: "retain-on-failure",
|
|
38
|
-
trace: "retain-on-failure",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Accessibility testing configuration with axe-core
|
|
44
|
-
*/
|
|
45
|
-
export const accessibilityConfig: PlaywrightTestConfig = {
|
|
46
|
-
testDir: "./tests/acceptance/accessibility",
|
|
47
|
-
testMatch: "**/*.{test,spec}.{ts,js}",
|
|
48
|
-
|
|
49
|
-
use: {
|
|
50
|
-
// Slower execution for accessibility checks
|
|
51
|
-
actionTimeout: 15000,
|
|
52
|
-
navigationTimeout: 20000,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Performance testing configuration for Lighthouse integration
|
|
58
|
-
*/
|
|
59
|
-
export const performanceConfig: PlaywrightTestConfig = {
|
|
60
|
-
testDir: "./tests/acceptance/performance",
|
|
61
|
-
testMatch: "**/*.{test,spec}.{ts,js}",
|
|
62
|
-
|
|
63
|
-
// Sequential execution for accurate performance measurements
|
|
64
|
-
fullyParallel: false,
|
|
65
|
-
workers: 1,
|
|
66
|
-
|
|
67
|
-
use: {
|
|
68
|
-
// Extended timeouts for performance measurements
|
|
69
|
-
actionTimeout: 30000,
|
|
70
|
-
navigationTimeout: 45000,
|
|
71
|
-
|
|
72
|
-
// Minimal interference for accurate measurements
|
|
73
|
-
video: "off",
|
|
74
|
-
screenshot: "off",
|
|
75
|
-
trace: "off",
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Options for creating a cross-domain authentication workflow configuration.
|
|
81
|
-
*/
|
|
82
|
-
export interface AuthWorkflowOptions {
|
|
83
|
-
/** The cookie domain (e.g. ".example.com"). */
|
|
84
|
-
domain: string;
|
|
85
|
-
/**
|
|
86
|
-
* List of subdomains where authentication cookies should persist
|
|
87
|
-
* (e.g. ["accounts.example.com", "app.example.com"]).
|
|
88
|
-
*/
|
|
89
|
-
expectedPersistence: readonly string[];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Configuration shape returned by {@link createAuthWorkflowConfig}.
|
|
94
|
-
*/
|
|
95
|
-
export interface AuthWorkflowConfig {
|
|
96
|
-
/**
|
|
97
|
-
* Cookie settings used for cross-domain authentication.
|
|
98
|
-
*/
|
|
99
|
-
readonly cookieConfig: {
|
|
100
|
-
readonly domain: string;
|
|
101
|
-
readonly secure: true;
|
|
102
|
-
readonly httpOnly: true;
|
|
103
|
-
readonly sameSite: "lax";
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Subdomains where authentication should remain valid.
|
|
107
|
-
*/
|
|
108
|
-
readonly expectedPersistence: readonly string[];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Creates a cross-domain authentication configuration for the given domain.
|
|
113
|
-
* @param options - Domain and persistence settings
|
|
114
|
-
* @returns An authentication workflow config object
|
|
115
|
-
*/
|
|
116
|
-
export function createAuthWorkflowConfig(
|
|
117
|
-
options: AuthWorkflowOptions,
|
|
118
|
-
): AuthWorkflowConfig {
|
|
119
|
-
return {
|
|
120
|
-
cookieConfig: {
|
|
121
|
-
domain: options.domain,
|
|
122
|
-
secure: true,
|
|
123
|
-
httpOnly: true,
|
|
124
|
-
sameSite: "lax" as const,
|
|
125
|
-
},
|
|
126
|
-
expectedPersistence: options.expectedPersistence,
|
|
127
|
-
} as const;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Options for creating a cross-app Playwright configuration.
|
|
132
|
-
*/
|
|
133
|
-
export interface CrossAppConfigOptions {
|
|
134
|
-
/**
|
|
135
|
-
* Map of environment names to their configuration.
|
|
136
|
-
* The key used is determined by the `TEST_ENV` environment variable,
|
|
137
|
-
* falling back to `"development"`.
|
|
138
|
-
*/
|
|
139
|
-
environments: Readonly<Record<string, TestEnvironmentConfig | undefined>>;
|
|
140
|
-
/** Additional Playwright configuration overrides. */
|
|
141
|
-
customConfig?: PlaywrightConfig;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Creates a Playwright configuration for cross-app workflows.
|
|
146
|
-
*
|
|
147
|
-
* Consumers must supply their own environment map so that base URLs are not
|
|
148
|
-
* hardcoded in this shared package.
|
|
149
|
-
* @param options - Environments map and optional custom config overrides
|
|
150
|
-
* @returns A Playwright configuration optimized for cross-app testing
|
|
151
|
-
*/
|
|
152
|
-
export function createCrossAppConfig(
|
|
153
|
-
options: CrossAppConfigOptions,
|
|
154
|
-
): PlaywrightTestConfig {
|
|
155
|
-
const { environments, customConfig = EMPTY_CONFIG } = options;
|
|
156
|
-
|
|
157
|
-
const environment = process.env.TEST_ENV ?? "development";
|
|
158
|
-
const envConfig = environments[environment];
|
|
159
|
-
|
|
160
|
-
if (envConfig === undefined) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
`Unknown test environment "${environment}". Available environments: ${Object.keys(environments).join(", ")}`,
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const defaultBaseUrl = Object.values(envConfig.baseUrls).at(0);
|
|
167
|
-
|
|
168
|
-
if (defaultBaseUrl === undefined) {
|
|
169
|
-
throw new Error(
|
|
170
|
-
`Environment "${environment}" must define at least one base URL`,
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
...baseConfig,
|
|
176
|
-
...crossAppConfig,
|
|
177
|
-
...customConfig,
|
|
178
|
-
use: {
|
|
179
|
-
...baseConfig.use,
|
|
180
|
-
...crossAppConfig.use,
|
|
181
|
-
...(customConfig as PlaywrightTestConfig).use,
|
|
182
|
-
// Set base URL to the first entry in baseUrls (typically the landing page)
|
|
183
|
-
baseURL: defaultBaseUrl,
|
|
184
|
-
},
|
|
185
|
-
projects: [
|
|
186
|
-
// Desktop browsers for cross-app flows
|
|
187
|
-
{
|
|
188
|
-
name: "cross-app-chromium",
|
|
189
|
-
testDir: "./tests/acceptance/cross-app",
|
|
190
|
-
use: {
|
|
191
|
-
...baseConfig.projects?.[0]?.use,
|
|
192
|
-
// Cross-app specific browser settings
|
|
193
|
-
viewport: { width: 1920, height: 1080 },
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
name: "cross-app-firefox",
|
|
198
|
-
testDir: "./tests/acceptance/cross-app",
|
|
199
|
-
use: {
|
|
200
|
-
...baseConfig.projects?.[1]?.use,
|
|
201
|
-
viewport: { width: 1920, height: 1080 },
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
name: "cross-app-webkit",
|
|
206
|
-
testDir: "./tests/acceptance/cross-app",
|
|
207
|
-
use: {
|
|
208
|
-
...baseConfig.projects?.[2]?.use,
|
|
209
|
-
viewport: { width: 1920, height: 1080 },
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Creates a configuration for accessibility testing with axe-core
|
|
218
|
-
* @param customConfig - Additional configuration options
|
|
219
|
-
* @returns A Playwright configuration with accessibility testing setup
|
|
220
|
-
*/
|
|
221
|
-
export function createAccessibilityConfig(
|
|
222
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
223
|
-
): PlaywrightTestConfig {
|
|
224
|
-
return {
|
|
225
|
-
...baseConfig,
|
|
226
|
-
...accessibilityConfig,
|
|
227
|
-
...customConfig,
|
|
228
|
-
use: {
|
|
229
|
-
...baseConfig.use,
|
|
230
|
-
...accessibilityConfig.use,
|
|
231
|
-
...(customConfig as PlaywrightTestConfig).use,
|
|
232
|
-
},
|
|
233
|
-
projects: [
|
|
234
|
-
{
|
|
235
|
-
name: "accessibility-chromium",
|
|
236
|
-
testDir: "./tests/acceptance/accessibility",
|
|
237
|
-
use: {
|
|
238
|
-
...baseConfig.projects?.[0]?.use,
|
|
239
|
-
viewport: { width: 1280, height: 720 },
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Creates a configuration for performance testing with Lighthouse
|
|
248
|
-
* @param customConfig - Additional configuration options
|
|
249
|
-
* @returns A Playwright configuration with performance testing setup
|
|
250
|
-
*/
|
|
251
|
-
export function createPerformanceConfig(
|
|
252
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
253
|
-
): PlaywrightTestConfig {
|
|
254
|
-
return {
|
|
255
|
-
...baseConfig,
|
|
256
|
-
...performanceConfig,
|
|
257
|
-
...customConfig,
|
|
258
|
-
use: {
|
|
259
|
-
...baseConfig.use,
|
|
260
|
-
...performanceConfig.use,
|
|
261
|
-
...(customConfig as PlaywrightTestConfig).use,
|
|
262
|
-
},
|
|
263
|
-
projects: [
|
|
264
|
-
{
|
|
265
|
-
name: "performance-chromium",
|
|
266
|
-
testDir: "./tests/acceptance/performance",
|
|
267
|
-
use: {
|
|
268
|
-
...baseConfig.projects?.[0]?.use,
|
|
269
|
-
viewport: { width: 1920, height: 1080 },
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
],
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Creates a configuration optimized for authentication workflow testing
|
|
278
|
-
* @param options - Cross-app config options (environments map and optional custom config)
|
|
279
|
-
* @returns A Playwright configuration for auth workflow testing
|
|
280
|
-
*/
|
|
281
|
-
export function createAuthTestConfig(
|
|
282
|
-
options: CrossAppConfigOptions,
|
|
283
|
-
): PlaywrightTestConfig {
|
|
284
|
-
const { environments, customConfig = EMPTY_CONFIG } = options;
|
|
285
|
-
return createCrossAppConfig({
|
|
286
|
-
environments,
|
|
287
|
-
customConfig: {
|
|
288
|
-
...customConfig,
|
|
289
|
-
testDir: "./tests/acceptance/auth",
|
|
290
|
-
use: {
|
|
291
|
-
...(customConfig as PlaywrightTestConfig).use,
|
|
292
|
-
// No pre-authenticated state for auth tests
|
|
293
|
-
storageState: undefined,
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
export default createCrossAppConfig;
|
package/src/index.ts
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base Playwright configuration for all applications
|
|
3
|
-
* @module @reasonabletech/config-playwright
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { type PlaywrightTestConfig, devices } from "@playwright/test";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Recursively makes all properties of `T` readonly.
|
|
10
|
-
*
|
|
11
|
-
* Useful for configuration objects defined with `as const`, ensuring callers
|
|
12
|
-
* don't accidentally mutate shared config.
|
|
13
|
-
*/
|
|
14
|
-
export type DeepReadonly<T> = {
|
|
15
|
-
readonly [P in keyof T]: T[P] extends ReadonlyArray<infer U>
|
|
16
|
-
? ReadonlyArray<DeepReadonly<U>>
|
|
17
|
-
: T[P] extends Array<infer U>
|
|
18
|
-
? ReadonlyArray<DeepReadonly<U>>
|
|
19
|
-
: T[P] extends object
|
|
20
|
-
? DeepReadonly<T[P]>
|
|
21
|
-
: T[P];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Immutable Playwright config type accepted by config helpers.
|
|
26
|
-
*/
|
|
27
|
-
export type PlaywrightConfig = DeepReadonly<PlaywrightTestConfig>;
|
|
28
|
-
|
|
29
|
-
// Empty readonly config for default parameters
|
|
30
|
-
const EMPTY_CONFIG = {} as const satisfies PlaywrightConfig;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Service configuration for a test environment.
|
|
34
|
-
*/
|
|
35
|
-
export interface TestEnvironmentServices {
|
|
36
|
-
/** Whether to use real backend services instead of mocks. */
|
|
37
|
-
useRealServices: boolean;
|
|
38
|
-
/** Whether to mock external (third-party) API calls. */
|
|
39
|
-
mockExternalAPIs: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Configuration for a single test environment (e.g. development, staging, production).
|
|
44
|
-
*
|
|
45
|
-
* Consumers define their own environment map and pass it to helpers like
|
|
46
|
-
* {@link createCrossAppConfig} in `cross-app.ts`.
|
|
47
|
-
*/
|
|
48
|
-
export interface TestEnvironmentConfig {
|
|
49
|
-
/** Map of application names to their base URLs. */
|
|
50
|
-
baseUrls: Record<string, string>;
|
|
51
|
-
/** Service-layer settings for this environment. */
|
|
52
|
-
services: TestEnvironmentServices;
|
|
53
|
-
/** When true, only smoke tests should run (e.g. in production). */
|
|
54
|
-
smokeTestsOnly?: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Base configuration options that apply to all acceptance test environments
|
|
59
|
-
*/
|
|
60
|
-
export const baseConfig: PlaywrightTestConfig = {
|
|
61
|
-
// Test discovery and execution
|
|
62
|
-
testDir: "./tests/acceptance",
|
|
63
|
-
testMatch: "**/*.{test,spec}.{ts,js}",
|
|
64
|
-
|
|
65
|
-
// Global test settings
|
|
66
|
-
fullyParallel: true,
|
|
67
|
-
forbidOnly: Boolean(process.env.CI),
|
|
68
|
-
retries: process.env.CI !== undefined ? 2 : 0,
|
|
69
|
-
workers: process.env.CI !== undefined ? 4 : undefined,
|
|
70
|
-
|
|
71
|
-
// Test execution timeouts
|
|
72
|
-
timeout: 30 * 1000, // 30 seconds for individual tests
|
|
73
|
-
expect: {
|
|
74
|
-
timeout: 5 * 1000, // 5 seconds for assertions
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
// Reporter configuration for different environments
|
|
78
|
-
reporter: [
|
|
79
|
-
["html", { outputFolder: "./generated/playwright/reports" }],
|
|
80
|
-
["json", { outputFile: "./generated/playwright/results.json" }],
|
|
81
|
-
process.env.CI !== undefined ? ["github"] : ["list"],
|
|
82
|
-
],
|
|
83
|
-
|
|
84
|
-
// Output folder for test results
|
|
85
|
-
outputDir: "./generated/playwright/test-results",
|
|
86
|
-
|
|
87
|
-
// Global test options
|
|
88
|
-
use: {
|
|
89
|
-
// Browser context settings
|
|
90
|
-
viewport: { width: 1280, height: 720 },
|
|
91
|
-
ignoreHTTPSErrors: true,
|
|
92
|
-
headless: true, // Always headless by default (use --headed flag to override)
|
|
93
|
-
|
|
94
|
-
// Action timeouts
|
|
95
|
-
actionTimeout: 10 * 1000, // 10 seconds for actions
|
|
96
|
-
navigationTimeout: 30 * 1000, // 30 seconds for navigation
|
|
97
|
-
|
|
98
|
-
// Debugging and artifact collection - sensible defaults
|
|
99
|
-
trace: "on-first-retry",
|
|
100
|
-
video: "retain-on-failure",
|
|
101
|
-
screenshot: "only-on-failure",
|
|
102
|
-
|
|
103
|
-
// No authentication state by default (apps can override)
|
|
104
|
-
storageState: undefined,
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
// Browser and device matrix
|
|
108
|
-
// Local dev: Chromium only for speed
|
|
109
|
-
// CI: Full browser matrix for compatibility testing
|
|
110
|
-
projects:
|
|
111
|
-
process.env.CI !== undefined
|
|
112
|
-
? [
|
|
113
|
-
// Desktop browsers
|
|
114
|
-
{
|
|
115
|
-
name: "chromium",
|
|
116
|
-
use: { ...devices["Desktop Chrome"] },
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "firefox",
|
|
120
|
-
use: { ...devices["Desktop Firefox"] },
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
name: "webkit",
|
|
124
|
-
use: { ...devices["Desktop Safari"] },
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
// Mobile devices
|
|
128
|
-
{
|
|
129
|
-
name: "Mobile Chrome",
|
|
130
|
-
use: { ...devices["Pixel 5"] },
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "Mobile Safari",
|
|
134
|
-
use: { ...devices["iPhone 12"] },
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
// Tablet devices
|
|
138
|
-
{
|
|
139
|
-
name: "iPad",
|
|
140
|
-
use: { ...devices["iPad Pro"] },
|
|
141
|
-
},
|
|
142
|
-
]
|
|
143
|
-
: [
|
|
144
|
-
// Local development: Chromium only for fast iteration
|
|
145
|
-
{
|
|
146
|
-
name: "chromium",
|
|
147
|
-
use: { ...devices["Desktop Chrome"] },
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
|
|
151
|
-
// Development server integration - common defaults for web apps
|
|
152
|
-
webServer:
|
|
153
|
-
process.env.CI !== undefined
|
|
154
|
-
? undefined
|
|
155
|
-
: {
|
|
156
|
-
command: "pnpm dev",
|
|
157
|
-
reuseExistingServer: true,
|
|
158
|
-
timeout: 120 * 1000, // 2 minutes to start
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Creates a merged configuration from the base and any custom options
|
|
164
|
-
* @param customConfig - Additional configuration options
|
|
165
|
-
* @returns A merged Playwright configuration
|
|
166
|
-
*/
|
|
167
|
-
export function createPlaywrightConfig(
|
|
168
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
169
|
-
): PlaywrightTestConfig {
|
|
170
|
-
return {
|
|
171
|
-
...baseConfig,
|
|
172
|
-
...customConfig,
|
|
173
|
-
use: {
|
|
174
|
-
...baseConfig.use,
|
|
175
|
-
...customConfig.use,
|
|
176
|
-
},
|
|
177
|
-
projects: customConfig.projects ?? baseConfig.projects,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Creates a configuration optimized for CI/CD environments
|
|
183
|
-
* @param customConfig - Additional configuration options
|
|
184
|
-
* @returns A Playwright configuration optimized for CI/CD
|
|
185
|
-
*/
|
|
186
|
-
export function createCIConfig(
|
|
187
|
-
customConfig: PlaywrightConfig = EMPTY_CONFIG,
|
|
188
|
-
): PlaywrightTestConfig {
|
|
189
|
-
return createPlaywrightConfig({
|
|
190
|
-
...customConfig,
|
|
191
|
-
fullyParallel: true,
|
|
192
|
-
retries: 3,
|
|
193
|
-
workers: 4,
|
|
194
|
-
use: {
|
|
195
|
-
...customConfig.use,
|
|
196
|
-
trace: "retain-on-failure",
|
|
197
|
-
video: "retain-on-failure",
|
|
198
|
-
screenshot: "only-on-failure",
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Re-export for convenience
|
|
204
|
-
export { createCrossAppConfig } from "./cross-app.js";
|
|
205
|
-
export { createBaseConfig } from "./base.js";
|
|
206
|
-
|
|
207
|
-
export default createPlaywrightConfig;
|