From a finished feature to a passing wallet test
The loop to run after you implement a dapp feature and before you call it done. A wallet feature that has only been reasoned about is not finished; it is finished when a real extension has driven it and left evidence.
1. Name the user-visible flow you just built
Write one sentence in the user's words: "a visitor connects their wallet and sends 1 STX". If you cannot, the feature is not testable yet — go back to the code.
Then list, from the diff, every point where the dapp hands control to the wallet. Each one is a popup, and each popup is a step in the test:
| You added | The wallet does |
|---|---|
| a connect button | opens a connection-approval popup |
| a send / swap / mint call | opens a transaction-confirmation popup |
| an EIP-712 / permit signature | opens a signature popup (not a transaction popup) |
| a chain-specific read | nothing, but the wallet must already be on that network |
2. Add test ids to what you just built
The test drives your dapp through its own UI. Give every element the flow touches a stable
data-testid now, while the code is fresh: the connect button, the action button, and the element
that displays the result (address, transaction id, balance). Selectors based on visible text break
the first time someone rewords a label.
3. Write the test
Read the guide for your wallet — metamask-evm or leather-stacks — and follow its example. The
shape is always the same:
- import the wallet
- put it on the right network
- connect it to your dapp
- queue the dapp click inside the driver's
triggercallback, never click it yourself - assert on your dapp's own rendered result
- for anything on-chain, poll for the receipt
Step 4 is the one that catches people. The driver starts listening for the popup before it runs
your callback; a click made outside that callback opens the popup with nobody listening, and the
test dies on an opaque timeout. bdd covers the same rule for Gherkin steps.
4. Assert on the chain, not on the popup closing
A closed popup proves the user clicked confirm. It does not prove the transaction was broadcast, mined, or successful — a reverted transaction closes the popup exactly like a successful one.
Use waitForTransactionMined (Stacks) or waitForEthTransactionMined (EVM) and assert the returned
status. This is the single most common way a wallet test passes while the feature is broken.
5. Run it and collect reviewer evidence
Prefer the @wallets-e2e/mcp tools when they are connected. Do not shell out to Playwright if
list_projects is available.
list_projects— pick the id of this dapp's Playwright project.start_runwith that id, optionaltestFileorgrepto focus the new coverage. It returns arunIdimmediately. A testnet confirmation can take ~10 minutes; poll, do not block.- Poll
get_rununtilstateis notrunning. Readexecuted. Zero executed is a failure even when the process exited 0 (the usual cause is an unbuilt extension). get_reporton every finished run, pass or fail. It returns the HTML report, every video, every screenshot, every trace, and embeds representative screenshots so the reviewer can see the wallet popup here.get_artifactfor any extra screenshot worth showing. Point the reviewer at the video paths and HTML report for the full end-to-end transaction.
If MCP is not connected, ask the user to add npx -y @wallets-e2e/mcp with WALLETS_E2E_MCP_ROOT
set to this dapp, then fall back to:
npx playwright test
npx playwright show-reportA pass without video of the wallet or dapp is incomplete evidence. The reviewer must be able to
watch the real popups and on-chain flow. Prefer the primary attachment named video (an mp4 of
full-size frames built from screenshots; a WebM means videoSource: 'chromium'), displaying its
absolute path through the client's local video player when available, or through the HTML report,
or build the evidence site (get_report with evidence: true, or wallets-e2e-evidence). A
request to connect, approve, and deposit needs that complete journey in the recording; a
connection-only clip is insufficient. Prove each write with settleWrite from @wallets-e2e/core
(hash → receipt → state), never with the popup closing.
setup-and-reporting covers the artifact configuration; troubleshooting maps common symptoms to
causes.
6. Fix, and re-run the same test
Change one thing at a time and re-run. A wallet test that passes only sometimes is a real finding about your dapp, not noise to retry away: races between the dapp's state and the wallet's, or an assertion that fires before the chain has caught up, are genuine bugs your users will hit.
Definition of done
- Every popup the feature opens is exercised by a test.
- Every on-chain effect is asserted from a receipt, not from the popup closing.
- The run reports a non-zero
executedcount. - The reviewer has the HTML report, at least one video of the dapp or wallet, and representative screenshots (wallet confirmation + dapp result).
- The failure path was seen at least once — force a failure and confirm the report shows it, so you know the test can actually fail.
- No secret is hardcoded; the seed comes from the environment.