This is a collection of tools for testing metamask, metamask flask and metamask snaps.
npm install metamask-testing-toolsThis is a collection of tools for testing metamask, metamask flask and metamask snaps with Playwright.
``bash`
pnpm add metamask-testing-tools -D
This package is meant to be used with Playwright. It provides a createFixture function that returns a test and expect function that can be used to write tests.
More information on writing tests with Playwright can be found here.
`js
// tests.spec.js
import { createFixture } from 'metamask-testing-tools'
const { test, expect } = createFixture({
download: {
flask: true,
},
snap: {
snapId: 'npm:@filsnap',
},
})
test('should get address mainnet', async ({ metamask, page }) => {
const result = await metamask.invokeSnap({
request: {
method: 'fil_getAddress',
},
page,
})
expect(result).toBe('f1jbnosztqwadgh4smvsnojdvwjgqxsmtzy5n5imi')
})
`
Check
These variables can be used to override the default values.
- GITHUB_TOKEN - GitHub API token to download metamask from github releases.METAMASK_TAG
- - Tag of metamask to download. Defaults to latest.METAMASK_MNEMONIC
- - Seed to use for metamask.METAMASK_PASSWORD
- - Password to use for metamask.METAMASK_SNAP_ID
- - Snap ID to use for metamask.METAMASK_SNAP_VERSION` - Snap version to use for metamask.
-