Skip to content

Latest commit

 

History

History

tools

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

metamask-testing-tools

This is a collection of tools for testing metamask, metamask flask and metamask snaps with Playwright.

Install

pnpm add metamask-testing-tools -D

Usage

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.

// 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')
})

Docs

Check https://hugomrdias.github.io/filsnap-testing/modules/metamask_testing_tools.html

ENV variables

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.