Automated browser tests for Stellar apps

Drive your app like a real user, with a wallet your test controls.

e2e/wallet.spec.ts
import { expect, test, units, xlm } from 'stardust-stellar/test';
import { CONTRACTS } from '../src/contracts';

const { router, usdc } = CONTRACTS.testnet;

test.use({
  stardust: {
    users: {
      trader: {
        wallet: 'varial',
        connected: true,
        accounts: { main: { fund: '500' } },
      },
      friend: {},
    },
  },
});

test('swaps 10 XLM for USDC', async ({ users: { trader } }) => {
  await trader.page.goto('/swap');
  await trader.page.getByLabel('You pay').fill('10');
  await trader.page.getByRole('button', { name: 'Swap' }).click();

  const prompt = await trader.wallet.nextPrompt('signTransaction');
  expect(prompt).toInvoke({
    contract: router,
    fn: 'swap_exact_in',
    args: { amount_in: xlm('10') },
  });
  await expect(prompt).toLand();
  await expect(prompt).toChangeBalance(trader.account.address, usdc, {
    min: units('1', 7),
  });
});

test('asks to switch to testnet', async ({ users: { trader } }) => {
  await trader.wallet.switchNetwork('futurenet');
  await trader.page.goto('/swap');

  await expect(trader.page.getByText('Switch to testnet')).toBeVisible();
});

test('sends 5 XLM on testnet', async ({ users: { trader, friend } }) => {
  await trader.page.goto('/send');
  await trader.page.getByLabel('To').fill(friend.account.address);
  await trader.page.getByLabel('Amount').fill('5');
  await trader.page.getByRole('button', { name: 'Send' }).click();

  const prompt = await trader.wallet.nextPrompt('signTransaction');
  expect(prompt).toHaveOperation({
    type: 'payment',
    destination: friend.account.address,
    amount: xlm('5'),
  });
});
Terminal

$ npx stardust test

stardustnetworktestnet (https://soroban-testnet.stellar.org, protocol 30) readystardustbrowserchromium readystardustapppnpm dev -> http://localhost:3000 readystardustwalletsVarial 5.53.0, SEP-43 1.2.1, SEP-60 0.1.0

Running 3 tests using 3 workers

✓ 1e2e/wallet.spec.ts:19:1 › swaps 10 XLM for USDC (17.2s)
✓ 2e2e/wallet.spec.ts:36:1 › asks to switch to testnet (4.1s)
✘ 3e2e/wallet.spec.ts:43:1 › sends 5 XLM on testnet (6.3s)

1) e2e/wallet.spec.ts:43:1 › sends 5 XLM on testnet

StardustError PROTOCOL_VIOLATION: Stardust: 1 protocol violation in this test

p1 signTransaction missingNetworkPassphrase

The app sent signTransaction without networkPassphrase, so Varial reads it as mainnet.

Pass the passphrase of the wallet's network, "Test SDF Network ; September 2015".

Timeline:

0.0stradergetAddress
0.8stradersignTransactionpayment(destination: GD7Q…NX4E, asset: native, amount: 50000000) rejected (networkMismatch)
0.8straderviolationp1 missingNetworkPassphrase

Screenshot, trace and timeline: stardust-results/wallet-sends-5-XLM-on-testnet/

1 failed

e2e/wallet.spec.ts:43:1 › sends 5 XLM on testnet

2 passed (18.4s)

stardustappstopped

Every wallet flow, under test

Real wallet behaviour

Varial and SEP-60 wallets, checked every night against the real Varial extension.

Any wallet state

No wallet, connected, locked, on the wrong network, or holding several accounts.

Funded accounts

Fresh testnet accounts with XLM in every test, even in parallel.

Prompts on your terms

Approve, reject, fail or ignore any prompt, with a policy or from the test.

Checks on chain

Check contract calls, balance changes and events on the network.

Clear failures

A screenshot, a trace and the wallet's timeline for every failed test.

Roadmap

What works today, and what comes next.

Available now

1.0
  • Varial (formerly Freighter)the default wallet
  • SEP-60 and SEP-43wallet discovery and API
  • Stellar Wallets Kit2.7 and 2.8
  • Testnet and futurenetor your own RPC

Coming next

Planned
  • More walletsxBull, LOBSTR, Hana, Albedo, Rabet
  • Passkey smart walletssign with a passkey
  • Simulated RPC failurestimeouts, busy network
  • App templatestests set up in one command
  • Existing accountskeys you already have