npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@finn_gal/patchright-wallet-mock-ts

v1.0.0

Published

Mock Web3 Browser wallets, like Metamask, in Patchright tests.

Readme

Playwright Wallet Mock TS

A TypeScript library for mocking Web3 browser wallets (like MetaMask) in Playwright tests. This package provides a simple way to simulate wallet interactions in your dApp tests.

Features

  • Mock Ethereum wallet (MetaMask-like) in Playwright tests
  • Support for EIP-1193 standard
  • Local API server for making wallet requests
  • Automatic port allocation for the API server
  • TypeScript support

Installation

npm install @finn_gal/playwright-wallet-mock-ts

Usage

Basic Usage

import { chromium } from "playwright";
import { installMockWallet } from "@finn_gal/playwright-wallet-mock-ts";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
import { http } from "viem";

async function testDapp() {
  const browser = await chromium.launch({
    headless: false,
  });
  const context = await browser.newContext();
  const page = await context.newPage();
  
  // Install the mock wallet
  await installMockWallet({
    page,
    account: privateKeyToAccount(
      "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", // Example private key (don't use in production)
    ),
    defaultChain: mainnet,
    transports: { [mainnet.id]: http() },
    debug: true,
  });

  // Navigate to your dApp
  await page.goto("https://your-dapp-url.com");
  
  // Your wallet is now available in the page as window.ethereum
  // You can interact with your dApp as if MetaMask was installed
  
  await browser.close();
}

testDapp().catch(console.error);

Making EIP-1193 Requests

The library sets up a local API server that handles EIP-1193 requests. In the browser context, you can use window.eip1193Request to make requests:

// In browser context
const accounts = await window.eip1193Request({
  method: "eth_accounts",
  params: []
});

const balance = await window.eip1193Request({
  method: "eth_getBalance",
  params: [accounts[0], "latest"]
});

API Reference

installMockWallet(options)

Installs a mock wallet in the Playwright page.

Options:

  • page: Playwright Page object
  • account: Viem LocalAccount object
  • transports (optional): Record of chain ID to Transport mappings
  • defaultChain (optional): Default chain to use
  • debug (optional): Enable debug logging
  • wallet (optional): Use a pre-configured wallet instance instead of creating a new one

eip1193Request Parameters

  • method: The EIP-1193 method to call (e.g., "eth_accounts", "eth_getBalance")
  • params: Array of parameters for the method
  • uuid: Wallet UUID (automatically managed by the library)
  • debug: Enable debug logging

Examples

Testing a Connect Wallet Button

import { test, expect } from "@playwright/test";
import { installMockWallet } from "@finn_gal/playwright-wallet-mock-ts";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
import { http } from "viem";

test("connect wallet button works", async ({ page }) => {
  await installMockWallet({
    page,
    account: privateKeyToAccount(
      "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
    ),
    defaultChain: mainnet,
    transports: { [mainnet.id]: http() },
    debug: true,
  });

  await page.goto("https://your-dapp-url.com");
  
  // Click the connect wallet button
  await page.getByRole("button", { name: "Connect Wallet" }).click();
  
  // Check if the wallet address is displayed
  await expect(page.getByText("0x71C7656EC7ab88b098defB751B7401B5f6d8976F")).toBeVisible();
});

License

ISC