Skip to content

E2E testing library for web3 wallet extensions in Playwright.

License

Notifications You must be signed in to change notification settings

Maksandre/w3wallets

Repository files navigation

w3wallets

License npm version CodeQL Tests

Web3 wallets for Playwright.

This library provides methods for interacting with Web3 wallets using Playwright.

npm install -D w3wallets

Getting Started

The Backpack and the Polkadot{.js} wallets are currently supported.

Backpack Logo Polkadot JS Logo

1. Download wallets

npx w3wallets backpack polkadotJS

The unzipped files should be stored in the .w3wallets/<wallet-name> directory. Add them to .gitignore.

2. Wrap your fixture withWallets

Install needed wallets into the chromium using withWallets.

// your-fixture.ts
import { withWallets } from "w3wallets";
import { test as base } from "@playwright/test";

export const test = withWallets(base, 'backpack', 'polkadotJS').extend<BaseFixture>({
  magic: (_, use) => use(42),
});

type BaseFixture = {
  magic: number;
};

export { expect } from "@playwright/test";

3. Use the installed wallets in tests

import { test } from "./your-fixture";

test("Can use wallet", async ({ page, backpack }) => {
  const privateKey =
    "4wDJd9Ds5ueTdS95ReAZGSBVkjMcNKbgZk47xcmqzpUJjCt7VoB2Cs7hqwXWRnopzXqE4mCP6BEDHCYrFttEcBw2";

  await backpack.onboard("Eclipse", privateKey);
});