Quick Start

Get a mock Freighter wallet running in your Playwright tests in under 5 minutes.

1. Install

1npm install github:SentinelFi/stellar_wallet_mock
2npm install -D @playwright/test
3npx playwright install chromium

2. Write your first test

tests/wallet.spec.tstypescript
1import { test, expect } from "@playwright/test";
2import { installMockStellarWallet } from "stellar-wallet-mock";
3
4const SECRET_KEY = "SDPDMYEWFZEL6MW37FTPNTPZFYU2QYX4MLDSA7QBS4VSNZL5JL4IKDVQ";
5
6test("dApp connects to mock wallet", async ({ page }) => {
7 // Install the mock BEFORE navigating
8 await installMockStellarWallet({
9 page,
10 secretKey: SECRET_KEY,
11 });
12
13 await page.goto("http://localhost:5173");
14
15 // Your dApp now sees a connected Freighter wallet
16 await expect(page.locator(".wallet-address")).toBeVisible();
17});

Important

You must call installMockStellarWallet() before page.goto(). The mock needs to intercept messages from the moment the page loads.

3. Run

1npx playwright test

What just happened?

The mock wallet injected itself into the browser page and intercepted all window.postMessage calls that Freighter would normally handle. Your dApp thinks it's talking to a real Freighter extension, but the mock is responding with real cryptographic signatures using your secret key.

It also pre-seeded localStorage keys so dApps using stellar-wallets-kit or Scaffold Stellar boot directly into a connected state.