Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
755a721
Refactor wallet structure
Maksandre Dec 11, 2025
374898a
Refactor wallet exports and improve configuration structure
Maksandre Dec 11, 2025
453084d
Add test-dapp package with initial configuration and dependencies
Maksandre Dec 11, 2025
0c657c8
Remove test-contracts package and update test-dapp configuration for …
Maksandre Dec 11, 2025
95ca805
Update test-dapp configuration and components
Maksandre Dec 11, 2025
ce6a893
Add ERC-20 token functionality to test-dapp
Maksandre Dec 11, 2025
ec1f5a3
Refactor test-dapp to integrate ERC-721 NFT functionality and streaml…
Maksandre Dec 11, 2025
50c51c6
Add SignMessageSection component to test-dapp for signing messages fu…
Maksandre Dec 11, 2025
5a14f64
add infra
Maksandre Dec 12, 2025
7bbadfa
Сonditionally display ERC-20 and ERC-721 sections based on environment
Maksandre Dec 15, 2025
f1c10a1
Enhance w3wallets CLI with short aliases and detailed help options
Maksandre Dec 15, 2025
e2e3300
Enhance withWallets function to derive Chrome extension IDs from mani…
Maksandre Dec 15, 2025
451a17c
add metamask functionality
Maksandre Dec 15, 2025
6d8b060
Fix codestyle
Maksandre Dec 15, 2025
3c6ee1e
Update w3wallets package version to 1.0.0-beta.1
Maksandre Dec 15, 2025
5f4d58d
Restore pjs test
Maksandre Dec 15, 2025
db6d992
remove backpack
Maksandre Dec 15, 2025
3f30e6c
remove test-app
Maksandre Dec 15, 2025
06a88b3
fix CI
Maksandre Dec 15, 2025
af76498
Update peer dependency for @playwright/test to version 1.57.0
Maksandre Dec 15, 2025
3863708
Add recursive submodule checkout in Playwright CI workflow
Maksandre Dec 15, 2025
d02e168
Refactor start script for test-dapp to improve deployment process
Maksandre Dec 15, 2025
78d5bfd
Enhance start script for test-dapp to build and run Next.js productio…
Maksandre Dec 15, 2025
90e8615
Do not remova pages in fixture
Maksandre Dec 16, 2025
0a77136
Update Metamask onboarding page URL and increase button visibility ti…
Maksandre Dec 16, 2025
b8a7a44
Refactor Metamask onboarding process to improve mnemonic input handli…
Maksandre Dec 16, 2025
236c03d
Implement configurable action timeout for wallet interactions and upd…
Maksandre Dec 16, 2025
6d25d5d
Refactor Metamask interactions to remove hardcoded timeouts, utilizin…
Maksandre Dec 17, 2025
3d88124
Replace Hardhat references with Anvil
Maksandre Dec 18, 2025
f3725ea
Add erc-20 tests
Maksandre Dec 18, 2025
6823e67
fix
Maksandre Dec 18, 2025
5e687f4
fix format
Maksandre Dec 18, 2025
0649a4f
Update w3wallets version to 1.0.0-beta.3 in package.json
Maksandre Dec 23, 2025
03b2c82
Merge branch 'main' into release-1.0.0
Maksandre Jan 1, 2026
ce224b8
One worker on CI
Maksandre Jan 12, 2026
f903245
fix ci
Maksandre Feb 1, 2026
183706c
increase workers
Maksandre Feb 1, 2026
14448db
Squashed commit of the following:
Maksandre Feb 1, 2026
ce3877c
add cahce script
Maksandre Feb 1, 2026
392c542
add expect timeout
Maksandre Feb 1, 2026
ab85a8b
update playwright
Maksandre Feb 1, 2026
0ddd0b0
update lock file
Maksandre Feb 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: "Playwright Tests"
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.57.0-noble
image: mcr.microsoft.com/playwright:v1.58.1-noble
env:
NEXT_PUBLIC_WC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_WC_PROJECT_ID }}
steps:
Expand Down Expand Up @@ -55,8 +55,16 @@ jobs:
- name: 🖨 Copy test envs
run: cp packages/w3wallets/.env.example packages/w3wallets/.env

- name: 🔨 Build w3wallets
run: yarn build
working-directory: packages/w3wallets

- name: 🗄️ Build wallet cache
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' npx w3wallets cache tests/wallets-cache/
working-directory: packages/w3wallets

- name: 🧪 Run tests
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' yarn test
run: xvfb-run --auto-servernum --server-args='-screen 0 1280x800x24' yarn test:ci

- name: Upload test artifacts
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"deploy": "yarn workspace @w3wallets/test-dapp deploy",
"build": "yarn workspace w3wallets build",
"download-wallets": "yarn workspace w3wallets download-wallets",
"test": "yarn workspace w3wallets test"
"test": "yarn workspace w3wallets test",
"test:ci": "yarn workspace w3wallets test:ci"
},
"packageManager": "yarn@4.6.0",
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/w3wallets/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ETHEREUM_PRIVATE_KEY1=0x903518e191f3843d017f0f9611cfdd27c655565917887faf2762549e
ETHEREUM_MNEMONIC2=typical flock crash unique wage turtle become trim legend diet dance kitchen
ETHEREUM_PRIVATE_KEY2=0xbf80a3a6906d48c828b1f3a71ee529092375557f3ab4d3088f1e9495cdb7b624
SUBSTRATE_SEED=focus inspire onion claw ski jaguar kidney screen bike kiss icon aerobic
W3WALLETS_ACTION_TIMEOUT=60000
W3WALLETS_ACTION_TIMEOUT=60000
W3WALLETS_EXPECT_TIMEOUT=60000
59 changes: 59 additions & 0 deletions packages/w3wallets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,65 @@ test("Can connect MetaMask to dApp", async ({ page, metamask }) => {
});
```

## Caching

Wallet onboarding can be slow. Caching lets you run the setup once and reuse the browser profile across tests.

#### 1. Create a setup file

Create a `*.cache.ts` file in a `wallets-cache/` directory (default):

```ts
// wallets-cache/default.cache.ts
import { prepareWallet, metamask } from "w3wallets";

export default prepareWallet(metamask, async (wallet, page) => {
await wallet.onboard("your seed phrase ...", "YourPassword123!");
});
```

#### 2. Build the cache

```sh
npx w3wallets cache
```

<details>
<summary>CLI Options</summary>

```
USAGE:
npx w3wallets cache [OPTIONS] [directory]

OPTIONS:
-f, --force Force rebuild even if cache exists
--headed Run browser in headed mode
directory Directory containing *.cache.{ts,js} files (default: ./wallets-cache/)
```

</details>

The cached profiles are stored in `.w3wallets/cache/`. The `.w3wallets` directory should already be in `.gitignore`.

#### 3. Use cached wallets in tests

Import the setup and pass it to `withWallets`:

```ts
import { test as base, expect } from "@playwright/test";
import { withWallets } from "w3wallets";
import cachedMetamask from "./wallets-cache/default.cache";

const test = withWallets(base, cachedMetamask);

test("wallet is ready", async ({ metamask }) => {
await metamask.unlock("YourPassword123!");
// wallet is already onboarded
});
```

> **Note:** All wallets in a test must be either all cached or all non-cached.

## Configuration

Configure library behavior via environment variables:
Expand Down
6 changes: 3 additions & 3 deletions packages/w3wallets/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "w3wallets",
"description": "browser wallets for playwright",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://github.com/Maksandre/w3wallets",
Expand Down Expand Up @@ -31,7 +31,7 @@
"bin": "./src/scripts/download.js",
"scripts": {
"download-wallets": "npx w3wallets pjs mm",
"test": "npx playwright test --project=local --workers=2",
"test": "npx playwright test --project=local",
"test:ci": "npx playwright test --project=ci",
"build": "tsup",
"clean": "rm -rf dist",
Expand All @@ -46,7 +46,7 @@
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.2",
"@changesets/cli": "^2.27.11",
"@playwright/test": "1.57.0",
"@playwright/test": "1.58.1",
"@types/node": "^22.10.5",
"dotenv": "^16.4.7",
"prettier": "^3.4.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/w3wallets/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export default defineConfig({
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
// retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 1 : 0,
/* Opt out of parallel tests on CI. */
// workers: process.env.CI ? 1 : undefined,
workers: process.env.CI ? 2 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
Loading