You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: domains/testing/skills/e2e-testing/repos/metamask-extension.md
+79Lines changed: 79 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -417,6 +417,84 @@ The following patterns are prohibited in test specs:
417
417
awaitsomePage.waitForLoadingToComplete();
418
418
```
419
419
420
+
4.**Test-Step Helpers Belong in Page Objects or Flow Files, Not Spec Files**
421
+
422
+
Spec files must not define helper functions that perform test steps (UI interactions or multi-step navigation). Spec files should read as a sequence of high-level page object and flow calls. Inline step helpers hide test steps, cannot be reused across specs, and bypass the Page Object Model / Flow structure the framework mandates.
423
+
424
+
**Decision rule for where the logic belongs:**
425
+
426
+
- Touches a **single** page object → add a **method to that Page Object class**.
427
+
- Orchestrates **more than one** page object → move it to a **Flow file** (`test/e2e/page-objects/flows/*.flow.ts`).
428
+
429
+
> This applies to helpers that perform **test steps** (UI/navigation/step logic). Small pure-data utilities are not the target.
430
+
431
+
The example below touches three page objects (`HeaderNavbar`, `SettingsPage`, `SyncAccountsSettingsPage`), so it belongs in a flow file.
432
+
433
+
❌ Incorrect — helper function performing test steps defined inside the `.spec.ts` file:
If the logic had touched only **one** page object, the correct fix would instead be to add a method to that page object class rather than create a flow.
497
+
420
498
## Handling Flaky Tests
421
499
422
500
### Common Issues and Solutions
@@ -515,6 +593,7 @@ Before submitting E2E tests, ensure:
515
593
-[ ] Page Object pattern used for all UI interactions
516
594
-[ ] Element selectors defined in page objects, not in test specs
517
595
-[ ] No hardcoded selectors in test files
596
+
-[ ] No test-step/navigation helper functions defined in spec files — extract to a page object method (single page) or a flow file (multiple pages)
518
597
-[ ] Proper TypeScript type annotations used for variables and method parameters
4.**Test-Step Helpers Belong in Page Objects or Flow Files, Not Spec Files**
246
+
247
+
Spec files must not define helper functions that perform test steps (UI interactions or multi-step navigation). Spec files should read as a sequence of high-level page object and flow calls. Inline step helpers hide test steps, cannot be reused across specs, and bypass the Page Object Model / Flow structure the framework mandates.
248
+
249
+
**Decision rule for where the logic belongs:**
250
+
251
+
- Touches a **single** page object → add a **method to that Page Object class**.
252
+
- Orchestrates **more than one** page object → move it to a **Flow file** (`e2e/flows/*.flow.ts`, e.g. the existing `flows/wallet.flow.ts`).
253
+
254
+
> This applies to helpers that perform **test steps** (UI/navigation/step logic). Small pure-data utilities are not the target.
255
+
256
+
The example below touches three page objects (`TabBarComponent`, `SettingsView`, `SyncAccountsSettingsView`), so it belongs in a flow file.
257
+
258
+
❌ Incorrect — helper function performing test steps defined inside the `.spec.ts` file:
If the logic had touched only **one** page object, the correct fix would instead be to add a method to that page object class rather than create a flow.
318
+
245
319
## Handling Flaky Tests
246
320
247
321
### Common Issues and Solutions
@@ -302,6 +376,7 @@ Before submitting E2E tests, ensure:
302
376
-[ ] All gestures have descriptive `description` parameters
303
377
-[ ] Appropriate timeouts for operations (not magic numbers)
304
378
-[ ] Page Object pattern used for complex interactions
379
+
-[ ] No test-step/navigation helper functions defined in spec files — extract to a page object method (single page) or a flow file (multiple pages)
305
380
-[ ] Element selectors defined once and reused
306
381
-[ ] Framework configuration used appropriately
307
382
-[ ] Error handling for expected failure scenarios
0 commit comments