mock
Signs for real, sends nothing. For UI tests and for Vitest + jsdom, where registerTestWallet() replaces a hand-written mock-wallet.ts.
const { wallet } = await registerTestWallet({ accounts: ["alice"] });
Open source · MIT · for Playwright and Vitest
A real Wallet Standard wallet your dApp lists next to Phantom — except the approve button is a line in your Playwright test. Connect, sign, send, cancel, fail, switch accounts. In CI. No extension, no devnet.
npm i -D @solana-e2e/wallet @solana-e2e/playwright
Four GitHub code searches (1, 2, 3, 4) return more than 100 files of hand-written Wallet Standard mocks injected into Playwright, across dozens of repositories — including Uniswap and ZeroDev — and none of them is a reusable package.
| Feature | Driving a real extension | Hand-written mock | solana-e2e |
|---|---|---|---|
| No extension download, runs headless | No | Yes | Yes |
signAndSendTransaction, signIn | Yes | Rarely | Yes |
| Reject, fail, approve from the test | Through popups | If you write it | One line each |
Several accounts, change events | Yes | Rarely | Yes |
| Transaction checked on a local chain | Needs setup | Rarely | Fixture included |
| Maintained once, for everyone | Popups change | Copied per repo | npm package |
A small dApp and, next to it, the real @solana-e2e/wallet running in this tab in mock mode, with the buttons a test would press. Every click becomes a line of the Playwright spec below. Nothing leaves your browser unless you point the wallet at your own local chain.
Loading the test wallet…
mock mode the request stops at the TestWallet: it signs and answers, and nothing is sent. In rpc mode it continues to Surfpool. The playground above skips the Playwright bridge: the shell and the TestWallet both run inside your tab.Hover or tap a step to follow it in the diagram.
Your dApp finds the wallet withgetWallets(), exactly as it finds Phantom or Solflare. Nothing in your app changes.
A tiny Wallet Standard object is registered in the page. It holds no keys: it forwards every call and returns the answer.
Calls cross from the browser to the test process through page.exposeFunction. That is why your test can control the wallet directly.
The TestWallet holds throwaway keys and decides what the user does: rejectNext(), failNext(), approve(), switchAccount().
Only in rpc mode: the signed transaction is sent to a local Surfpool chain and confirmed, and localnet.getTransaction() tells you what landed.
The user cancels
wallet.rejectNext({ method: "signMessage" })The wallet or the network fails
wallet.failNext({ code: -32002, message: "Blockhash not found" })A request waits for approval
wallet.setApproval("manual"); … wallet.approve()The user switches account mid-flow
wallet.switchAccount("bob")A wallet without sign-and-send
{ disabledFeatures: ["solana:signAndSendTransaction"] }An unsupported transaction version
{ supportedTransactionVersions: ["legacy", 0] }autoConnect on an untrusted site (the default)
{ trusted: false }An extension that loads late
installTestWallet(page, { late: true })mockSigns for real, sends nothing. For UI tests and for Vitest + jsdom, where registerTestWallet() replaces a hand-written mock-wallet.ts.
const { wallet } = await registerTestWallet({ accounts: ["alice"] });
rpcSigns, sends to a local RPC and waits for the commitment. With @solana-e2e/playwright you get a Surfpool chain per worker and a funded wallet per test.
const tx = await localnet.getTransaction(signature);
expect(tx.logs).toContain("Program log: hello");
Mock-mode specs need nothing but Playwright. For rpc mode, install Surfpool from its release and check the archive's sha256; the full GitHub Actions recipe is in docs/ci.md. This project's own CI runs both kinds on Linux, macOS and Windows.
mock mode.