Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
4799a2f
fix changelog
joaoloureirop Feb 20, 2026
5b312f8
Cherry-picking commits from main to release/7.67.0 for PR #26292 (#26…
runway-github[bot] Feb 20, 2026
9f71945
[skip ci] Bump version number to 3764
metamaskbot Feb 20, 2026
a96cf72
Cherry-picking commits from main to release/7.67.0 for PR #26312 (#26…
runway-github[bot] Feb 23, 2026
be65488
[skip ci] Bump version number to 3779
metamaskbot Feb 23, 2026
433eb10
chore(runway): cherry-pick chore: New Crowdin translations by Github …
runway-github[bot] Feb 24, 2026
968afc6
[skip ci] Bump version number to 3784
metamaskbot Feb 24, 2026
8f1ce83
chore(runway): cherry-pick fix(perps): connection-aware ensureReady()…
runway-github[bot] Feb 24, 2026
3769a8c
[skip ci] Bump version number to 3785
metamaskbot Feb 24, 2026
a31e92d
chore(runway): cherry-pick fix: Fix StorageService Key Encoding cp-7.…
runway-github[bot] Feb 20, 2026
347dd4c
chore(runway): cherry-pick fix: cp-7.66.0 refresh staked balance afte…
runway-github[bot] Feb 20, 2026
43b3ddb
chore(runway): cherry-pick refactor(musd): replace decodeMerklClaimAm…
runway-github[bot] Feb 20, 2026
e7e9109
chore(runway): cherry-pick chore: allow list audit finding GHSA-378v-…
runway-github[bot] Feb 23, 2026
f694aa8
chore(runway): cherry-pick chore(predict): cp-7.66.0 remove code rela…
runway-github[bot] Feb 23, 2026
a88e9a2
chore(runway): cherry-pick feat: cp-7.66.0 MUSD-357 added musd_conver…
runway-github[bot] Feb 23, 2026
f3e85e0
Revert "fix: MUL-1331 modify android manifest file for correct BLE lo…
joaoloureirop Feb 17, 2026
6765ad5
feat: Fix for pull to refresh gesture bug
MarioAslau Feb 20, 2026
e372c9c
release: release/7.66.0-Changelog (#26044)
metamaskbot Feb 23, 2026
f1b7400
Merge branch 'stable' into stable-merge-7.67.0
joaoloureirop Feb 24, 2026
c0f721f
chore: merge stable into release 7.67.0 branch (#26496)
joaoloureirop Feb 24, 2026
a6b6df6
[skip ci] Bump version number to 3787
metamaskbot Feb 24, 2026
860b51d
bump semvar version to 7.66.1 && build version to 3788
metamaskbot Feb 24, 2026
d7d2c3d
update changelog for 7.66.1 (hotfix - no test plan)
metamaskbot Feb 24, 2026
2363997
chore(runway): cherry-pick 9b336fc (#26494)
runway-github[bot] Feb 24, 2026
2bb99c8
[skip ci] Bump version number to 3789
metamaskbot Feb 24, 2026
0452203
revert version back to 7.66.0
weitingsun Feb 24, 2026
56dff68
[skip ci] Bump version number to 3790
metamaskbot Feb 24, 2026
9037bab
Revert "[skip ci] Bump version number to 3790"
joaoloureirop Feb 24, 2026
5a0adad
update OTA version
weitingsun Feb 24, 2026
d6ab5b1
Merge branch 'release/7.66.1' of github.com:MetaMask/metamask-mobile …
weitingsun Feb 24, 2026
3b31dc8
chore(runway): cherry-pick chore: remove process.env spread (#26528)
runway-github[bot] Feb 25, 2026
a64cba2
fix: bnjs audit issue (#26481)
bergarces Feb 24, 2026
e6447f9
[skip ci] Bump version number to 3799
metamaskbot Feb 25, 2026
8360a74
chore(runway): cherry-pick fix: MUSD-368 fixed left-aligned header ti…
runway-github[bot] Feb 25, 2026
4509cde
[skip ci] Bump version number to 3800
metamaskbot Feb 25, 2026
ad68f51
chore(runway): cherry-pick 1b1705e (#26551)
runway-github[bot] Feb 25, 2026
7a7eb4a
chore(runway): cherry-pick fix(ramps): gate RampsController.init() be…
runway-github[bot] Feb 25, 2026
2f7112d
[skip ci] Bump version number to 3801
metamaskbot Feb 25, 2026
6384078
chore(runway): cherry-pick fix: redirect to market details page after…
runway-github[bot] Feb 25, 2026
7dbe51a
chore(runway): cherry-pick fix: fix spl token redirection to block ex…
runway-github[bot] Feb 25, 2026
086c9a5
[skip ci] Bump version number to 3804
metamaskbot Feb 25, 2026
35f8c01
chore(runway): cherry-pick fix: perps verbose when clearing subscript…
runway-github[bot] Feb 25, 2026
42fca9d
[skip ci] Bump version number to 3805
metamaskbot Feb 25, 2026
86362e8
chore(runway): cherry-pick fix(card): resolve screen freeze when dis…
runway-github[bot] Feb 25, 2026
85a6b83
[skip ci] Bump version number to 3806
metamaskbot Feb 25, 2026
f365105
chore(runway): cherry-pick fix: add optional abtest to more swaps and…
runway-github[bot] Feb 25, 2026
a2a4fe9
[skip ci] Bump version number to 3807
metamaskbot Feb 25, 2026
d06b101
chore(runway): cherry-pick fix: bnjs audit issue (#26627)
chloeYue Feb 26, 2026
87003b2
chore(runway): cherry-pick refactor: Updated affected pages to use Sa…
runway-github[bot] Feb 26, 2026
d5e6fbf
[skip ci] Bump version number to 3814
metamaskbot Feb 26, 2026
37c9992
add changelog for ota 7.66.1
weitingsun Feb 26, 2026
5c4fbb5
Merge branch 'stable' into release/7.67.0
joaoloureirop Feb 26, 2026
d1cd8e8
chore(runway): cherry-pick fix: AccountsApiBalanceFetcher stricter ze…
runway-github[bot] Feb 26, 2026
d4a6f2b
[skip ci] Bump version number to 3817
metamaskbot Feb 26, 2026
88bcdb7
chore(runway): cherry-pick f07db0a (#26647)
runway-github[bot] Feb 26, 2026
29dcf19
[skip ci] Bump version number to 3823
metamaskbot Feb 26, 2026
588a4fa
[skip ci] Bump version number to 3837
metamaskbot Feb 27, 2026
acb3b62
update changelog
joaoloureirop Feb 27, 2026
d35f874
Merge branch 'release/7.66.1' into release-changelog/7.66.1
joaoloureirop Feb 27, 2026
034d750
Merge branch 'stable' into release/7.66.1
joaoloureirop Feb 27, 2026
92eb648
update changelog for 7.66.1 (hotfix - no test plan)
metamaskbot Feb 27, 2026
e66f5d6
release: release/7.66.0-Changelog (#26044)
metamaskbot Feb 23, 2026
5afb0df
Merge branch 'release/7.66.1' into release-changelog/7.66.1
joaoloureirop Feb 27, 2026
a747f37
chore(runway): cherry-pick fix(bridge): cp-7.67.0 display block explo…
runway-github[bot] Feb 27, 2026
45d3e53
chore(runway): cherry-pick fix(bridge): cp-7.67.0 fix "View on block …
runway-github[bot] Feb 27, 2026
f3fc796
[skip ci] Bump version number to 3840
metamaskbot Feb 27, 2026
6bd436b
[skip ci] Bump version number to 3842
metamaskbot Feb 27, 2026
c34449e
Revert "feat(card): integrate Veriff native SDK with MetaMask brandin…
joaoloureirop Feb 27, 2026
2757e55
[skip ci] Bump version number to 3843
metamaskbot Feb 27, 2026
b1c3e3e
[skip ci] Bump version number to 3844
metamaskbot Feb 27, 2026
624b19f
release: 7.66.1 (#26508)
joaoloureirop Feb 27, 2026
305cde1
Merge branch 'stable' into release/7.67.0
joaoloureirop Feb 27, 2026
0c23991
release: release-changelog/7.67.0 (#26313)
metamaskbot Feb 27, 2026
bb8a18a
Merge branch 'stable' into release/7.68.0
joaoloureirop Feb 27, 2026
dceca8a
release: 7.67.0 (#26310)
joaoloureirop Feb 27, 2026
c4acb0b
bump semvar version to 7.67.1 && build version to 3854
metamaskbot Mar 2, 2026
35d793b
chore(runway): cherry-pick chore: Bump `json-rpc-engine` cp-7.68.0 (#…
runway-github[bot] Mar 2, 2026
eefde10
revert version number back to 7.67.0
weitingsun Mar 2, 2026
6e7c0ff
chore(runway): cherry-pick fix: recipient list display in send flow c…
runway-github[bot] Mar 2, 2026
d0be88d
[skip ci] Bump version number to 3855
metamaskbot Mar 2, 2026
d346622
chore(runway): cherry-pick fix(perps): recover connection after app s…
runway-github[bot] Mar 2, 2026
8155e01
update OTA version
weitingsun Mar 2, 2026
dec6a1d
chore(runway): cherry-pick feat(card): cp-7.68.0 Add View PIN option …
runway-github[bot] Mar 3, 2026
c0576fc
[skip ci] Bump version number to 3868
metamaskbot Mar 3, 2026
6a6fc20
chore(runway): cherry-pick fix: Bump @metamask/transaction-pay-contro…
runway-github[bot] Mar 3, 2026
5c7c134
[skip ci] Bump version number to 3873
metamaskbot Mar 3, 2026
5f8c7c0
chore(runway): cherry-pick feat: stocks section in explore cp-7.68.0 …
runway-github[bot] Mar 3, 2026
347c072
[skip ci] Bump version number to 3874
metamaskbot Mar 3, 2026
9ad6bba
chore(runway): cherry-pick fix: cp-7.68.0 Bump `TransactionPayControl…
runway-github[bot] Mar 3, 2026
c82785e
[skip ci] Bump version number to 3875
metamaskbot Mar 3, 2026
2529967
chore(runway): cherry-pick fix(perps): recover connection after app s…
runway-github[bot] Mar 3, 2026
8be47b3
[skip ci] Bump version number to 3877
metamaskbot Mar 3, 2026
cfc3688
chore(runway): cherry-pick fix(predict): prediction market positions …
runway-github[bot] Mar 4, 2026
80e6909
[skip ci] Bump version number to 3885
metamaskbot Mar 4, 2026
adb545e
chore(runway): cherry-pick fix(perps): remove duplicate AppState list…
runway-github[bot] Mar 4, 2026
66ff689
OTA update 7.67.2
joaoloureirop Mar 4, 2026
9214d78
bump semvar version to 7.67.3 && build version to 3896
metamaskbot Mar 5, 2026
0243c56
chore(runway): cherry-pick 02ac109 (#27041)
runway-github[bot] Mar 5, 2026
c194f0b
chore(runway): cherry-pick chore: Bump `snaps-controllers` cp-7.67.2 …
runway-github[bot] Mar 5, 2026
dcf639d
[skip ci] Bump version number to 3899
metamaskbot Mar 5, 2026
bd044f7
[skip ci] Bump version number to 3901
metamaskbot Mar 5, 2026
a282970
chore(runway): cherry-pick fix: MUSD-450 extract Merkl bonus claim l…
runway-github[bot] Mar 5, 2026
c6b2b41
[skip ci] Bump version number to 3902
metamaskbot Mar 5, 2026
eb3d209
Merge branch 'stable' into release/7.67.1
joaoloureirop Mar 5, 2026
99754f1
chore(runway): cherry-pick chore: Bump snaps-controllers (#26992) (#2…
runway-github[bot] Mar 5, 2026
a7e73d4
[skip ci] Bump version number to 3904
metamaskbot Mar 5, 2026
fce0e5c
chore(runway): cherry-pick fix: Ensure redux-persist-filesystem-stora…
runway-github[bot] Mar 5, 2026
d35f89b
chore(runway): cherry-pick 86cb8a3 (#27081)
runway-github[bot] Mar 5, 2026
a81706d
[skip ci] Bump version number to 3907
metamaskbot Mar 5, 2026
68361f6
chore(runway): cherry-pick fix(perps): remove duplicate AppState list…
runway-github[bot] Mar 5, 2026
d2074cf
[skip ci] Bump version number to 3908
metamaskbot Mar 5, 2026
56726a8
release: 7.67.1 (#26799)
joaoloureirop Mar 5, 2026
444b662
Merge branch 'stable' into release/7.67.2
joaoloureirop Mar 5, 2026
7712237
release: 7.67.2 (#26985)
joaoloureirop Mar 5, 2026
8bc8e7d
Merge branch 'stable' into release/7.67.3
joaoloureirop Mar 5, 2026
744fd59
release: release-changelog/7.67.3 (#27063)
chloeYue Mar 5, 2026
d23b341
release: 7.67.3 (#27040)
joaoloureirop Mar 6, 2026
81200b6
chore(runway): cherry-pick feat: MUSD-394 add generic transaction fee…
runway-github[bot] Mar 6, 2026
bc63b68
[skip ci] Bump version number to 3927
metamaskbot Mar 6, 2026
4aea9bd
chore(runway): cherry-pick fix(perps): recover HIP-3 DEX discovery on…
runway-github[bot] Mar 6, 2026
051cd43
[skip ci] Bump version number to 3928
metamaskbot Mar 6, 2026
019be1b
[skip ci] Bump version number to 3929
metamaskbot Mar 6, 2026
b628a7d
chore(runway): cherry-pick chore: New Crowdin translations by Github …
runway-github[bot] Mar 6, 2026
c92ad30
chore(runway): cherry-pick fix(ramps): ensure Buy tokens load on toke…
runway-github[bot] Mar 6, 2026
1f5be81
[skip ci] Bump version number to 3931
metamaskbot Mar 6, 2026
39f5e4f
[skip ci] Bump version number to 3933
metamaskbot Mar 6, 2026
f07e950
Revert "fix: MUL-1331 modify android manifest file for correct BLE lo…
joaoloureirop Mar 6, 2026
097a7d1
[skip ci] Bump version number to 3934
metamaskbot Mar 6, 2026
8426333
[skip ci] Bump version number to 3935
metamaskbot Mar 6, 2026
fb9776a
Revert "feat(card): integrate Veriff native SDK with MetaMask brandin…
joaoloureirop Mar 7, 2026
d8f0371
[skip ci] Bump version number to 3939
metamaskbot Mar 7, 2026
3f6baad
chore: resolve merge conflicts for stable sync into release/7.68.0
chloeYue Mar 10, 2026
aa983be
chore: sync stable into release/7.68.0 (#27282)
chloeYue Mar 10, 2026
28a7e81
release: release-changelog/7.68.0 (#26655)
metamaskbot Mar 10, 2026
4ca049b
release: 7.68.0 (#26654)
chloeYue Mar 11, 2026
2e32657
Merge origin/main into stable-main-7.70.0
metamaskbot Mar 11, 2026
1c1f5c4
Merge branch 'main' into stable-main-7.70.0
chloeYue Mar 11, 2026
2e42212
feat: migrate Label (core ux scope) (#27283)
kirillzyusko Mar 11, 2026
e9c5f59
fix: update treatment sticky buy/sell cp-7.69.0 (#27285)
sahar-fehri Mar 11, 2026
756fbf0
fix: improve Google ACM error resilience and Sentry error segregation…
grvgoel81 Mar 11, 2026
86887ec
feat: add E2E test builder skill (#27062)
racitores Mar 11, 2026
b10be9a
chore: add rule about scroll view and react-native-gesture-handler (#…
infiniteflower Mar 11, 2026
813f853
chore: claim onboarding and SRP screens in CODEOWNERS for web3auth (#…
tylerc-consensys Mar 11, 2026
1b375da
fix: migration 121 remove exception missing nativeAssetIdentifiers (#…
maxime-oe Mar 11, 2026
8afc768
ci: add automation tests stats (#27337)
jvbriones Mar 11, 2026
012ef60
chore: sync stable to main for version 7.68.0 (#27094)
Gudahtt Mar 11, 2026
8ff2a61
fix: resolve iOS bundle executable case mismatch and missing permissi…
cmd-ob Mar 11, 2026
577859c
feat(agents): add PR workflow skills for AI coding agents (#27356)
NicolasMassart Mar 11, 2026
33cfed3
refactor: Updated headers for Predictions page - Unavailble BottomShe…
brianacnguyen Mar 11, 2026
3ac4c6e
fix: disable slide-to-dismiss behavior of swaps keypad (#26770)
GeorgeGkas Mar 11, 2026
2eacab6
fix: max button 7702 re-enable cp-7.69.0 (#27373)
ghgoodreau Mar 11, 2026
0a3bbfa
fix: bluetooth permissions check & disconnect on close (#27358)
mathieuartu Mar 11, 2026
47741a3
feat: add CashTokensFullView and integrate into MainNavigator (#27123)
PatrykLucka Mar 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .agents/skills/e2e-test/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: e2e-test
description:
Add and fix Detox E2E tests (smoke and regression) for MetaMask Mobile using
withFixtures, Page Objects, and tests/framework. Use when creating a new spec,
fixing a failing E2E test, or adding page objects and selectors.
---

# E2E Test Builder — Skill

> **One source of truth** for adding Detox E2E tests to MetaMask Mobile.
> Applies to: Claude Code (`.claude/commands/e2e-test.md`), Cursor, Copilot, Windsurf, and other AI agents.

**Before writing or changing any E2E code:** read this skill once, then open the reference(s) indicated by the decision tree for your task.

## What This Skill Does

Guides you through adding a new E2E regression or smoke test end-to-end:

1. Plans the test (type, location, infrastructure needed)
2. Creates or reuses Page Objects and selectors
3. Writes the spec using the mandatory framework patterns and the **correct tag** (see Golden rule 8; check `tests/tags.js` and existing specs in the feature folder)
4. Runs lint and type checks
5. Executes the test locally via Detox
6. Iterates until the test passes

Your job is to figure out whether the user needs to **write a new spec**, **fix a failing test**, or **add page objects/selectors**, then follow the corresponding path and open the relevant reference when that path indicates.

**Decision tree — which reference to use:**

```
Task → What do you need?
├─ Write new spec or add test steps
│ → Open references/writing-tests.md (spec structure, templates, FixtureBuilder patterns)
│ → If you need POM/selectors: also open references/page-objects.md
│ → If you need API or feature-flag mocks: also open references/mocking.md
│ → After writing: run lint/tsc, then open references/running-tests.md to run and debug
├─ Create or update Page Objects / selectors
│ → Open references/page-objects.md (POM structure, Matchers, Gestures, Assertions, selector conventions)
│ → When writing the spec: open references/writing-tests.md
├─ Mock API or feature flags
│ → Open references/mocking.md (testSpecificMock, setupRemoteFeatureFlagsMock, setupMockRequest)
│ → When writing the spec: open references/writing-tests.md
└─ Run tests, debug failures, or self-review
→ Open references/running-tests.md (build check, detox commands, common failures, retry patterns)
```

Do not read the full reference files until the decision tree or workflow sends you there.

---

## 10 Golden Rules

1. **Always use `withFixtures`** — every spec must be wrapped; no exceptions
2. **Always use Page Object Model** — no `element(by.id())` in spec files
3. **Always import from `tests/framework/index.ts`** — never from individual files
4. **Always add `description`** to every `Gestures.*` and `Assertions.*` call
5. **Never use `TestHelpers.delay()`** — use `Assertions.*` which has auto-retry
6. **Use `FixtureBuilder` for state** — do not set state through UI interactions
7. **Selectors live in `*.testIds.ts`** (co-located) or `tests/selectors/` (legacy)
8. **Tag correctly** — Use the tag that matches your feature and test type. Options include `SmokeE2E`, `SmokeTrade`, `SmokePredictions`, `SmokePerps`, `SmokeConfirmations`, `RegressionTrade`, `RegressionWallet`, etc. Check **`tests/tags.js`** for the full list and descriptions, and **existing specs in the same feature folder** to see which tag they use.
9. **Descriptive test names** — no 'should' prefix (e.g., `'opens market details'`)
10. **Fix lint/tsc before running** — never run with known errors

---

## Workflow Overview

```
Step 0 → Understand requirement + choose type (smoke/regression)
Step 1 → Discover / create Page Objects and selectors
Step 2 → Write the spec (withFixtures + POM + correct tag)
Step 3 → Lint + TSC (fix all errors)
Step 4 → Run detox test locally
Step 5 → Iterate (fix → lint → run) until green
```

---

## Reference files (when to use)

Documentation is split by **action**. Open only the reference that matches what you are doing.

| Action | File | When to open it |
| --------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **Writing or updating a spec** | [references/writing-tests.md](references/writing-tests.md) | New spec file, spec structure, FixtureBuilder patterns, smoke/regression templates. |
| **Page Objects and selectors** | [references/page-objects.md](references/page-objects.md) | Create or update POM classes, selector/testId conventions, Matchers/Gestures/Assertions API. |
| **API and feature flag mocking** | [references/mocking.md](references/mocking.md) | testSpecificMock, setupRemoteFeatureFlagsMock, setupMockRequest, shared mock files. |
| **Running tests, debugging, fixing failures** | [references/running-tests.md](references/running-tests.md) | Build check, detox run commands, lint/tsc, common failures table, retry patterns, iteration loop. |
4 changes: 4 additions & 0 deletions .agents/skills/e2e-test/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
interface:
display_name: "E2E Test"
short_description: "Add and fix Detox E2E smoke/regression tests for MetaMask Mobile."
default_prompt: "Use $e2e-test to add or fix E2E tests with withFixtures, Page Objects, and the tests/framework."
141 changes: 141 additions & 0 deletions .agents/skills/e2e-test/references/mocking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# API & Feature Flag Mocking — Reference

## How Mocking Works

All E2E tests run with a proxy mock server. Requests not matched by a mock reach the real network, but the test framework warns you (and will soon enforce this). Always mock external APIs your feature calls.

## testSpecificMock Pattern

Pass to `withFixtures` to apply mocks only for that test:

```typescript
import { Mockttp } from 'mockttp';
import { setupRemoteFeatureFlagsMock } from '../../api-mocking/helpers/remoteFeatureFlagsHelper';
import { setupMockRequest } from '../../api-mocking/mockHelpers';

const testSpecificMock = async (mockServer: Mockttp) => {
// Feature flags
await setupRemoteFeatureFlagsMock(mockServer, { myFeatureEnabled: true });

// GET request
await setupMockRequest(mockServer, {
requestMethod: 'GET',
url: 'https://api.example.com/data',
response: { items: [] },
responseCode: 200,
});
};

await withFixtures({ fixture: ..., testSpecificMock }, async () => { ... });
```

## Feature Flag Mocking

```typescript
import { setupRemoteFeatureFlagsMock } from '../../api-mocking/helpers/remoteFeatureFlagsHelper';

// Simple boolean flags
await setupRemoteFeatureFlagsMock(mockServer, {
predictTradingEnabled: true,
carouselBanners: false,
});

// Nested flags
await setupRemoteFeatureFlagsMock(mockServer, {
bridgeConfig: { support: true, refreshRate: 5000 },
});

// Flask distribution
await setupRemoteFeatureFlagsMock(mockServer, { perpsEnabled: true }, 'flask');

// Combine predefined configs
import { confirmationsRedesignedFeatureFlags } from '../../api-mocking/mock-responses/feature-flags-mocks';
await setupRemoteFeatureFlagsMock(
mockServer,
Object.assign({}, ...confirmationsRedesignedFeatureFlags, { myFlag: true }),
);
```

## HTTP Request Mocking

```typescript
import {
setupMockRequest,
setupMockPostRequest,
} from '../../api-mocking/mockHelpers';

// GET
await setupMockRequest(mockServer, {
requestMethod: 'GET',
url: 'https://api.example.com/resource',
response: { data: [] },
responseCode: 200,
});

// POST with body validation
await setupMockPostRequest(
mockServer,
'https://api.example.com/submit',
{ amount: '1000000000000000000' }, // expected request body
{ success: true }, // response
{ statusCode: 201, ignoreFields: ['timestamp', 'nonce'] },
);
```

## Shared Mock Response Files

For mocks used across multiple tests, create a file in `tests/api-mocking/mock-responses/`:

```typescript
// tests/api-mocking/mock-responses/predict-mocks.ts
import { MockApiEndpoint } from '../framework/types';

export const PREDICT_MOCKS = {
GET: [
{
urlEndpoint: 'https://predict.api.metamask.io/markets',
responseCode: 200,
response: { markets: [{ id: 'btc-usd', name: 'BTC above $100k?' }] },
},
] as MockApiEndpoint[],
};
```

Then pass directly to `withFixtures`:

```typescript
await withFixtures({ fixture: ..., testSpecificMock: PREDICT_MOCKS }, async () => { ... });
```

## Controller-Level Mocking (Advanced)

Only needed when the feature uses SDKs with complex transport (WebSockets, custom protocols) that can't be intercepted at the HTTP level.

- Implement a mixin in `tests/controller-mocking/mock-config/`
- See `tests/docs/CONTROLLER_MOCKING.md` for details
- Prefer HTTP-level mocking whenever possible

## Debugging Unmocked Requests

Check test output for warnings like:

```
⚠️ Unmocked request: GET https://api.example.com/resource
```

Add a mock for every such request to ensure test determinism.

## Features using WebSockets or complex transport

Some features depend on **WebSockets** or other non-HTTP transport (e.g. Perps/HyperLiquid, real-time data). The HTTP mock server cannot intercept these. The repo uses two patterns:

1. **Controller-level mocking** — A mixin under `tests/controller-mocking/mock-config/` replaces provider SDK touchpoints so E2E runs with stable, test-controlled data. Example: `perps-controller-mixin.ts` for HyperLiquid. See **`tests/docs/CONTROLLER_MOCKING.md`** for when and how to use it.
2. **Command queue / test server** — Tests that need to drive the app (e.g. inject state or commands) can use **`CommandQueueServer`** (`tests/framework/fixtures/CommandQueueServer.ts`). Enable it in the fixture with `useCommandQueueServer: true`. Used by Perps specs (e.g. `tests/smoke/perps/perps-add-funds.spec.ts`, `tests/regression/perps/perps-limit-long-fill.spec.ts`). The app consumes the queue in E2E context.

**When adding support for a new feature that uses WebSockets or similar:**

- Follow the **same pattern** as existing features (controller mixin and/or CommandQueueServer).
- Implement under `tests/controller-mocking/mock-config/` or extend the command-queue protocol as needed.
- Add or update **tests/specs** that cover the mock infrastructure and the E2E flow.

Prefer HTTP mocking whenever the feature’s API is plain HTTP; use controller mocking or the command server only when necessary.
Loading
Loading