-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
133 lines (118 loc) · 3.95 KB
/
playwright.config.ts
File metadata and controls
133 lines (118 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* Root Playwright Configuration
*
* Delegates to the Playwright submodule test suite at:
* Tests/AngularNetTutorial-Playwright/tests/
*
* NOTE: Values are inlined here (not imported from the submodule) to avoid a
* dual-instance Playwright conflict. The root node_modules and the submodule
* node_modules contain different Playwright versions; cross-importing between
* them causes a runtime crash. Keep values in sync with:
* Tests/AngularNetTutorial-Playwright/config/test-config.ts
*
* Prefer running from the submodule for development:
* cd Tests/AngularNetTutorial-Playwright && npx playwright test
*
* Running from the repo root (CI / convenience):
* npx playwright test
* npx playwright test --project=screenshots
* npx playwright test --project=smoke
*/
import { defineConfig, devices } from '@playwright/test';
const ANGULAR_URL = process.env.ANGULAR_APP_URL || 'http://localhost:4200';
const API_URL = process.env.API_APP_URL || 'https://localhost:44378/api/v1';
const IDENTITY_URL = process.env.IDENTITY_SERVER_URL || 'https://localhost:44310';
const TESTS_DIR = './Tests/AngularNetTutorial-Playwright/tests';
const REPORT_DIR = './Tests/AngularNetTutorial-Playwright/playwright-report';
const RESULTS_DIR = './Tests/AngularNetTutorial-Playwright/test-results';
export default defineConfig({
testDir: TESTS_DIR,
timeout: 30000,
expect: { timeout: 5000 },
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { outputFolder: REPORT_DIR, open: 'never' }],
['json', { outputFile: `${RESULTS_DIR}/results.json` }],
['junit', { outputFile: `${RESULTS_DIR}/junit.xml` }],
['list'],
],
use: {
baseURL: ANGULAR_URL,
trace: 'on-first-retry',
video: 'retain-on-failure',
screenshot: 'only-on-failure',
viewport: { width: 1366, height: 768 },
ignoreHTTPSErrors: true,
actionTimeout: 10000,
},
projects: [
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
// Smoke — critical path only (CI)
{
name: 'smoke',
testMatch: /.*smoke\.spec\.ts/,
use: { ...devices['Desktop Chrome'], viewport: { width: 1366, height: 768 } },
dependencies: ['setup'],
},
// E2E — Chromium
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
viewport: { width: 1366, height: 768 },
launchOptions: {
args: ['--enable-precise-memory-info', '--disable-animations'],
},
},
dependencies: ['setup'],
},
// E2E — Firefox
{
name: 'firefox',
use: { ...devices['Desktop Firefox'], viewport: { width: 1366, height: 768 } },
dependencies: ['setup'],
},
// E2E — WebKit
{
name: 'webkit',
use: { ...devices['Desktop Safari'], viewport: { width: 1366, height: 768 } },
dependencies: ['setup'],
},
// API Integration Tests
{
name: 'api',
testMatch: /tests\/api\/.*\.spec\.ts/,
testIgnore: [
/tests\/api\/auth-api\.spec\.ts/,
/tests\/api\/cache-api\.spec\.ts/,
/tests\/api\/departments-api\.spec\.ts/,
/tests\/api\/employees-api\.spec\.ts/,
],
use: {
baseURL: API_URL,
extraHTTPHeaders: { Accept: 'application/json' },
},
},
// Blog Screenshots — captures key UI states for blog posts and documentation
// video: 'on' records the browser session as a .webm file per test.
// Run scripts/build-video.ps1 after the test to combine the PNG+WAV pairs
// into a single narrated MP4 slideshow (requires FFmpeg on PATH).
{
name: 'screenshots',
testMatch: /tests\/screenshots\/.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
viewport: { width: 1366, height: 768 },
video: 'on',
screenshot: 'off',
launchOptions: { slowMo: 150 },
},
},
],
});