Skip to main content
MetaMask class for interacting with the MetaMask extension in Cypress tests.

Constructors

new MetaMask()

Creates an instance of MetaMask.

Parameters

Returns

MetaMask

Properties

Methods

addNetwork()

Adds a new network to MetaMask.

Parameters

Returns

Promise<boolean> True if the network was added successfully

addNewAccount()

Adds a new account with the given name.

Parameters

Returns

Promise<boolean> True if the account was added successfully

addNewToken()

Adds a new token to MetaMask.

Returns

Promise<boolean> True if the token was added successfully

approveNewNetwork()

Approves adding a new network.

Returns

Promise<boolean> True if the new network was approved successfully

approveSwitchNetwork()

Approves switching to a new network.

Returns

Promise<boolean> True if the network switch was approved successfully

approveTokenPermission()

Approves token permission.

Parameters

Returns

Promise<boolean> True if the permission was approved, false otherwise

closeTransactionDetails()

Closes the transaction details view.

Returns

Promise<boolean> True if the transaction details were closed successfully, false otherwise

confirmSignature()

Confirms a signature request.

Returns

Promise<boolean> True if the signature was confirmed successfully, false otherwise

confirmTransaction()

Confirms a transaction.

Parameters

Returns

Promise<boolean> True if the transaction was confirmed successfully

confirmTransactionAndWaitForMining()

Confirms a transaction and waits for it to be mined.

Returns

Promise<boolean> True if the transaction was confirmed and mined successfully, false otherwise

connectToAnvil()

Connects to an Anvil node.

Parameters

Returns

Promise<boolean> True if the connection was successful, false otherwise

connectToDapp()

Connects MetaMask to a dApp.

Parameters

Returns

Promise<boolean> True if the connection was successful

createAnvilNode()

Creates an Anvil node for testing.

Parameters

Returns

Promise<{ "anvil": Anvil; "chainId": number; "rpcUrl": string; }> Object containing the Anvil instance, RPC URL, and chain ID

decrypt()

Decrypts a message.

Returns

Promise<boolean> True if the message was decrypted successfully, false otherwise

deployToken()

Deploys a token.

Returns

Promise<boolean> True if the token was deployed successfully

emptyAnvilNode()

Empties the Anvil node pool.

Returns

Promise<boolean> True if the operation was successful

getAccount()

Gets the current account name.

Returns

Promise<string> The current account name

getAccountAddress()

Gets the current account address.

Returns

Promise<string> The current account address

getNetwork()

Gets the current network name.

Returns

Promise<string> The current network name

goBackToHomePage()

Navigates back to the home page.

Returns

Promise<boolean> True if the navigation was successful

importWallet()

Imports a wallet using a seed phrase.

Parameters

Returns

Promise<boolean> True if the import was successful

importWalletFromPrivateKey()

Imports a wallet using a private key.

Parameters

Returns

Promise<boolean> True if the import was successful

lock()

Locks the MetaMask wallet.

Returns

Promise<boolean> True if the wallet was locked successfully

openSettings()

Opens the settings page.

Returns

Promise<boolean> True if the settings page was opened successfully

openSidebarMenu()

Opens a specific sidebar menu in the settings.

Parameters

Returns

Promise<boolean> True if the menu was opened successfully

openTransactionDetails()

Opens the details of a specific transaction.

Parameters

Returns

Promise<boolean> True if the transaction details were opened successfully, false otherwise

providePublicEncryptionKey()

Provides a public encryption key.

Returns

Promise<boolean> True if the key was provided successfully, false otherwise

rejectNewNetwork()

Rejects adding a new network.

Returns

Promise<boolean> True if the new network was rejected successfully

rejectSignature()

Rejects a signature request.

Returns

Promise<boolean> True if the signature was rejected successfully

rejectSwitchNetwork()

Rejects switching to a new network.

Returns

Promise<boolean> True if the network switch was rejected successfully

rejectTokenPermission()

Rejects token permission.

Returns

Promise<boolean> True if the permission was rejected successfully

rejectTransaction()

Rejects a transaction.

Returns

Promise<boolean> True if the transaction was rejected successfully

renameAccount()

Renames an account.

Parameters

Returns

Promise<boolean> True if the rename was successful

resetAccount()

Resets the current account.

Returns

Promise<boolean> True if the reset was successful

switchAccount()

Switches to the account with the given name.

Parameters

Returns

Promise<boolean> True if the switch was successful

switchNetwork()

Switches to the specified network.

Parameters

Returns

Promise<boolean> True if the switch was successful, false otherwise

toggleDismissSecretRecoveryPhraseReminder()

Toggles the dismissal of the secret recovery phrase reminder.

Returns

Promise<boolean> True if the toggle was successful

toggleShowTestNetworks()

Toggles the display of test networks.

Returns

Promise<boolean> True if the toggle was successful

unlock()

Unlocks the MetaMask wallet.

Returns

Promise<boolean> True if the wallet was unlocked successfully