notque/vexjoy-agent / skills/process/testing
testing
VerifiedTesting: TDD, E2E, test automation strategy (Vitest, coverage, CI), preferred patterns, test-value audits, verification, agent testing.
references/e2e-wallet-testing.md
View on GitHub# Wallet Testing Patterns (Web3 / MetaMask)
Patterns for testing Web3 wallet interactions via `addInitScript`.
Used when your application integrates with MetaMask or similar browser-extension wallets.
---
## Mock MetaMask with addInitScript
```typescript
// pages/Web3Page.ts
import { type Page, type Locator } from '@playwright/test';
export class Web3Page {
readonly page: Page;
readonly connectWalletButton: Locator;
readonly walletAddress: Locator;
readonly txStatus: Locator;
constructor(page: Page) {
this.page = page;
this.connectWalletButton = page.getByTestId('wallet-connect');
this.walletAddress = page.getByTestId('wallet-address');
this.txStatus = page.getByTestId('tx-status');
}
async injectMockEthereum(address = '0xABC123...') {
await this.page.addInitScript((addr) => {
(window as any).ethereum = {
isMetaMask: true,
selectedAddress: addr,
request: async ({ method }: { method: string }) => {
if (method === 'eth_requestAccounts') return [addr];
if (method === 'eth_accounts') return [addr];
if (method === 'eth_chainId') return '0x1';
if (method === 'eth_sendTransaction') return '0xMOCK_TX_HASH';
return null;
},
on: () => {},
removeListener: () => {},
};
}, address);
}
async goto() {
await this.injectMockEthereum();
await this.page.goto('/app');
await this.page.waitForLoadState('networkidle');
}
}
```
```typescript
// tests/e2e/features/wallet.spec.ts
import { test, expect } from '@playwright/test';
import { Web3Page } from '../../../pages/Web3Page';
test.describe('Wallet Connection', () => {
test('connects wallet and displays address', async ({ page }) => {
const web3 = new Web3Page(page);
await web3.goto();
await web3.connectWalletButton.click();
await expect(web3.walletAddress).toContainText('0xABC');
});
});
```
---
## Notes
- `addInitScript` runs before page scripts — the mock is available when the app initialises.
- For transaction hash assertions, use the mock return value `0xMOCK_TX_HASH`.
- Run wallet tests against mocks or local hardhat/anvil nodes so the suite stays deterministic and avoids real-network side effects.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |