JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1937
  • Score
    100M100P100Q111836F
  • License MIT

browser wallets for playwright

Package Exports

  • w3wallets
  • w3wallets/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (w3wallets) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

MetaMask, Backpack, and Polkadot{.js} wallets are currently supported.

Metamask Logo 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 with withWallets

Install the required wallets into 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

Most commonly, you will use the following methods:

  1. onboard: to set up your wallet
  2. approve: for operations that confirm actions
  3. deny: for actions that reject or cancel operations
import { test } from "./your-fixture";

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

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