stably 4.10.4 → 4.10.5

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.
Files changed (38) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/stably-plugin-cli/skills/browser-interaction-guide/SKILL.md +21 -0
  3. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/accessibility.md +359 -0
  4. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/annotations.md +526 -0
  5. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/assertions-waiting.md +361 -0
  6. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/browser-apis.md +391 -0
  7. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/browser-extensions.md +506 -0
  8. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/canvas-webgl.md +493 -0
  9. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/ci-cd.md +407 -0
  10. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/clock-mocking.md +364 -0
  11. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/component-testing.md +500 -0
  12. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/console-errors.md +420 -0
  13. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/debugging.md +491 -0
  14. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/electron.md +509 -0
  15. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/error-testing.md +360 -0
  16. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/file-operations.md +375 -0
  17. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/fixtures-hooks.md +417 -0
  18. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/flaky-tests.md +494 -0
  19. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/global-setup.md +434 -0
  20. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/i18n.md +508 -0
  21. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/iframes.md +403 -0
  22. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/locators.md +242 -0
  23. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/mobile-testing.md +409 -0
  24. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/multi-context.md +288 -0
  25. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/multi-user.md +393 -0
  26. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/network-advanced.md +452 -0
  27. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/page-object-model.md +315 -0
  28. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/performance-testing.md +476 -0
  29. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/performance.md +453 -0
  30. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/projects-dependencies.md +456 -0
  31. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/security-testing.md +430 -0
  32. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/service-workers.md +504 -0
  33. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/test-coverage.md +495 -0
  34. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/test-data.md +492 -0
  35. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/test-organization.md +361 -0
  36. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/third-party.md +464 -0
  37. package/dist/stably-plugin-cli/skills/playwright-best-practices/references/websockets.md +403 -0
  38. package/package.json +1 -1
@@ -0,0 +1,456 @@
1
+ # Projects & Dependencies
2
+
3
+ ## Table of Contents
4
+
5
+ 1. [Project Configuration](#project-configuration)
6
+ 2. [Project Dependencies](#project-dependencies)
7
+ 3. [Setup Projects](#setup-projects)
8
+ 4. [Filtering & Running Projects](#filtering--running-projects)
9
+ 5. [Sharing Configuration](#sharing-configuration)
10
+ 6. [Advanced Patterns](#advanced-patterns)
11
+
12
+ ## Project Configuration
13
+
14
+ ### Basic Multi-Browser Setup
15
+
16
+ ```typescript
17
+ // playwright.config.ts
18
+ import { defineConfig, devices } from "@playwright/test";
19
+
20
+ export default defineConfig({
21
+ projects: [
22
+ {
23
+ name: "chromium",
24
+ use: { ...devices["Desktop Chrome"] },
25
+ },
26
+ {
27
+ name: "firefox",
28
+ use: { ...devices["Desktop Firefox"] },
29
+ },
30
+ {
31
+ name: "webkit",
32
+ use: { ...devices["Desktop Safari"] },
33
+ },
34
+ ],
35
+ });
36
+ ```
37
+
38
+ ### Environment-Based Projects
39
+
40
+ ```typescript
41
+ export default defineConfig({
42
+ projects: [
43
+ {
44
+ name: "staging",
45
+ use: {
46
+ baseURL: "https://staging.example.com",
47
+ },
48
+ },
49
+ {
50
+ name: "production",
51
+ use: {
52
+ baseURL: "https://example.com",
53
+ },
54
+ },
55
+ {
56
+ name: "local",
57
+ use: {
58
+ baseURL: "http://localhost:3000",
59
+ },
60
+ },
61
+ ],
62
+ });
63
+ ```
64
+
65
+ ### Test Type Projects
66
+
67
+ ```typescript
68
+ export default defineConfig({
69
+ projects: [
70
+ {
71
+ name: "e2e",
72
+ testDir: "./tests/e2e",
73
+ use: { ...devices["Desktop Chrome"] },
74
+ },
75
+ {
76
+ name: "api",
77
+ testDir: "./tests/api",
78
+ use: { baseURL: "http://localhost:3000" },
79
+ },
80
+ {
81
+ name: "visual",
82
+ testDir: "./tests/visual",
83
+ use: {
84
+ ...devices["Desktop Chrome"],
85
+ viewport: { width: 1280, height: 720 },
86
+ },
87
+ },
88
+ ],
89
+ });
90
+ ```
91
+
92
+ ## Project Dependencies
93
+
94
+ ### Setup Dependency
95
+
96
+ ```typescript
97
+ export default defineConfig({
98
+ projects: [
99
+ // Setup project runs first
100
+ {
101
+ name: "setup",
102
+ testMatch: /.*\.setup\.ts/,
103
+ },
104
+
105
+ // Browser projects depend on setup
106
+ {
107
+ name: "chromium",
108
+ use: {
109
+ ...devices["Desktop Chrome"],
110
+ storageState: ".auth/user.json",
111
+ },
112
+ dependencies: ["setup"],
113
+ },
114
+ {
115
+ name: "firefox",
116
+ use: {
117
+ ...devices["Desktop Firefox"],
118
+ storageState: ".auth/user.json",
119
+ },
120
+ dependencies: ["setup"],
121
+ },
122
+ ],
123
+ });
124
+ ```
125
+
126
+ ### Multiple Auth States
127
+
128
+ ```typescript
129
+ export default defineConfig({
130
+ projects: [
131
+ // Auth setup projects
132
+ {
133
+ name: "setup-admin",
134
+ testMatch: /admin\.setup\.ts/,
135
+ },
136
+ {
137
+ name: "setup-user",
138
+ testMatch: /user\.setup\.ts/,
139
+ },
140
+
141
+ // Admin tests
142
+ {
143
+ name: "admin-tests",
144
+ testDir: "./tests/admin",
145
+ use: { storageState: ".auth/admin.json" },
146
+ dependencies: ["setup-admin"],
147
+ },
148
+
149
+ // User tests
150
+ {
151
+ name: "user-tests",
152
+ testDir: "./tests/user",
153
+ use: { storageState: ".auth/user.json" },
154
+ dependencies: ["setup-user"],
155
+ },
156
+
157
+ // Tests that need both
158
+ {
159
+ name: "integration-tests",
160
+ testDir: "./tests/integration",
161
+ dependencies: ["setup-admin", "setup-user"],
162
+ },
163
+ ],
164
+ });
165
+ ```
166
+
167
+ ### Chained Dependencies
168
+
169
+ ```typescript
170
+ export default defineConfig({
171
+ projects: [
172
+ // Step 1: Database setup
173
+ {
174
+ name: "db-setup",
175
+ testMatch: /db\.setup\.ts/,
176
+ },
177
+
178
+ // Step 2: Auth setup (needs DB)
179
+ {
180
+ name: "auth-setup",
181
+ testMatch: /auth\.setup\.ts/,
182
+ dependencies: ["db-setup"],
183
+ },
184
+
185
+ // Step 3: Seed data (needs auth)
186
+ {
187
+ name: "seed-setup",
188
+ testMatch: /seed\.setup\.ts/,
189
+ dependencies: ["auth-setup"],
190
+ },
191
+
192
+ // Tests (need everything)
193
+ {
194
+ name: "tests",
195
+ testDir: "./tests",
196
+ dependencies: ["seed-setup"],
197
+ },
198
+ ],
199
+ });
200
+ ```
201
+
202
+ ## Setup Projects
203
+
204
+ ### Authentication Setup
205
+
206
+ Setup projects are the recommended way to handle authentication. They run before your main test projects and can use Playwright fixtures.
207
+
208
+ > **For complete authentication patterns** (storage state, multiple auth states, auth fixtures), see [fixtures-hooks.md](fixtures-hooks.md#authentication-patterns).
209
+
210
+ ### Data Seeding Setup
211
+
212
+ ```typescript
213
+ // seed.setup.ts
214
+ import { test as setup } from "@playwright/test";
215
+
216
+ setup("seed test data", async ({ request }) => {
217
+ // Create test data via API
218
+ await request.post("/api/test/seed", {
219
+ data: {
220
+ users: 10,
221
+ products: 50,
222
+ orders: 100,
223
+ },
224
+ });
225
+ });
226
+ ```
227
+
228
+ ### Cleanup Setup
229
+
230
+ ```typescript
231
+ // cleanup.setup.ts
232
+ import { test as setup } from "@playwright/test";
233
+
234
+ setup("cleanup previous run", async ({ request }) => {
235
+ // Clean up data from previous test runs
236
+ await request.delete("/api/test/cleanup");
237
+ });
238
+ ```
239
+
240
+ ## Filtering & Running Projects
241
+
242
+ ### Run Specific Project
243
+
244
+ ```bash
245
+ # Run single project
246
+ npx playwright test --project=chromium
247
+
248
+ # Run multiple projects
249
+ npx playwright test --project=chromium --project=firefox
250
+
251
+ # Run all except one
252
+ npx playwright test --project=!webkit
253
+ ```
254
+
255
+ ### Run by Grep
256
+
257
+ ```bash
258
+ # Run tests matching pattern
259
+ npx playwright test --grep @smoke
260
+
261
+ # Run project with grep
262
+ npx playwright test --project=chromium --grep @critical
263
+
264
+ # Exclude pattern
265
+ npx playwright test --grep-invert @slow
266
+ ```
267
+
268
+ ### Project-Specific Grep
269
+
270
+ ```typescript
271
+ export default defineConfig({
272
+ projects: [
273
+ {
274
+ name: "smoke",
275
+ grep: /@smoke/,
276
+ use: { ...devices["Desktop Chrome"] },
277
+ },
278
+ {
279
+ name: "regression",
280
+ grepInvert: /@smoke/,
281
+ use: { ...devices["Desktop Chrome"] },
282
+ },
283
+ ],
284
+ });
285
+ ```
286
+
287
+ ## Sharing Configuration
288
+
289
+ ### Base Configuration
290
+
291
+ ```typescript
292
+ // playwright.config.ts
293
+ const baseConfig = {
294
+ timeout: 30000,
295
+ expect: { timeout: 5000 },
296
+ use: {
297
+ trace: "on-first-retry",
298
+ screenshot: "only-on-failure",
299
+ },
300
+ };
301
+
302
+ export default defineConfig({
303
+ ...baseConfig,
304
+ projects: [
305
+ {
306
+ name: "chromium",
307
+ use: {
308
+ ...baseConfig.use,
309
+ ...devices["Desktop Chrome"],
310
+ },
311
+ },
312
+ {
313
+ name: "firefox",
314
+ use: {
315
+ ...baseConfig.use,
316
+ ...devices["Desktop Firefox"],
317
+ },
318
+ },
319
+ ],
320
+ });
321
+ ```
322
+
323
+ ### Shared Project Settings
324
+
325
+ ```typescript
326
+ const sharedBrowserConfig = {
327
+ timeout: 60000,
328
+ retries: 2,
329
+ use: {
330
+ video: "on-first-retry",
331
+ trace: "on-first-retry",
332
+ },
333
+ };
334
+
335
+ export default defineConfig({
336
+ projects: [
337
+ {
338
+ name: "chromium",
339
+ ...sharedBrowserConfig,
340
+ use: {
341
+ ...sharedBrowserConfig.use,
342
+ ...devices["Desktop Chrome"],
343
+ },
344
+ },
345
+ {
346
+ name: "firefox",
347
+ ...sharedBrowserConfig,
348
+ use: {
349
+ ...sharedBrowserConfig.use,
350
+ ...devices["Desktop Firefox"],
351
+ },
352
+ },
353
+ ],
354
+ });
355
+ ```
356
+
357
+ ## Advanced Patterns
358
+
359
+ ### Conditional Projects
360
+
361
+ ```typescript
362
+ const projects = [
363
+ {
364
+ name: "chromium",
365
+ use: { ...devices["Desktop Chrome"] },
366
+ },
367
+ ];
368
+
369
+ // Add Firefox only in CI
370
+ if (process.env.CI) {
371
+ projects.push({
372
+ name: "firefox",
373
+ use: { ...devices["Desktop Firefox"] },
374
+ });
375
+ }
376
+
377
+ // Add mobile only for specific test dirs
378
+ if (process.env.TEST_MOBILE) {
379
+ projects.push({
380
+ name: "mobile",
381
+ use: { ...devices["iPhone 14"] },
382
+ });
383
+ }
384
+
385
+ export default defineConfig({ projects });
386
+ ```
387
+
388
+ ### Project Metadata
389
+
390
+ ```typescript
391
+ export default defineConfig({
392
+ projects: [
393
+ {
394
+ name: "chromium",
395
+ use: { ...devices["Desktop Chrome"] },
396
+ metadata: {
397
+ platform: "desktop",
398
+ browser: "chromium",
399
+ priority: "high",
400
+ },
401
+ },
402
+ ],
403
+ });
404
+
405
+ // Access in test
406
+ test("example", async ({ page }, testInfo) => {
407
+ const { platform, priority } = testInfo.project.metadata;
408
+ console.log(`Running on ${platform} with ${priority} priority`);
409
+ });
410
+ ```
411
+
412
+ ### Teardown Projects
413
+
414
+ ```typescript
415
+ export default defineConfig({
416
+ projects: [
417
+ {
418
+ name: "setup",
419
+ testMatch: /.*\.setup\.ts/,
420
+ teardown: "teardown", // Run teardown after this completes
421
+ },
422
+ {
423
+ name: "teardown",
424
+ testMatch: /.*\.teardown\.ts/,
425
+ },
426
+ {
427
+ name: "tests",
428
+ dependencies: ["setup"],
429
+ },
430
+ ],
431
+ });
432
+ ```
433
+
434
+ ```typescript
435
+ // cleanup.teardown.ts
436
+ import { test as teardown } from "@playwright/test";
437
+
438
+ teardown("cleanup", async ({ request }) => {
439
+ await request.delete("/api/test/data");
440
+ });
441
+ ```
442
+
443
+ ## Anti-Patterns to Avoid
444
+
445
+ | Anti-Pattern | Problem | Solution |
446
+ | -------------------------- | ---------------------- | ----------------------------------- |
447
+ | Too many browser projects | Slow CI, expensive | Focus on critical browsers |
448
+ | Missing setup dependencies | Tests fail randomly | Declare all dependencies explicitly |
449
+ | Duplicated configuration | Hard to maintain | Extract shared config |
450
+ | Not using setup projects | Repeated auth in tests | Use setup project + storageState |
451
+
452
+ ## Related References
453
+
454
+ - **Global Setup**: See [global-setup.md](global-setup.md) for globalSetup vs setup projects
455
+ - **Fixtures**: See [fixtures-hooks.md](fixtures-hooks.md) for authentication patterns
456
+ - **CI/CD**: See [ci-cd.md](ci-cd.md) for running projects in CI