Practical overview
When it fits
Use it when a dApp test needs controlled wallet or blockchain-provider responses rather than relying on live responses.
Who it is for
- Developers writing tests for decentralized applications.
- Teams using Jest, Cypress or Playwright to test wallet and provider interactions.
Documented uses
- Mock wallet responses in a dApp test.
- Set predictable results for blockchain RPC or contract requests.
- Exercise application behaviour against mocked provider responses.
Requirements & limits
- The README names Jest, Cypress and Playwright and says they should be set up before using the library.
- Solana examples require explicit provider mocking; the basic EVM example initializes an Ethereum mock directly.
- The repository specifies the MIT license.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install WEB3 Mock as a development dependency
Add the library to a JavaScript project before configuring a test runner.
Before you start
- A JavaScript project using Yarn or npm
Steps
Install @depay/web3-mock with Yarn using
yarn add @depay/web3-mock --dev, or with npm using the command below.npm install --save-dev @depay/web3-mockSet up Jest, Cypress or Playwright according to the project's guidance before using the library.
Expected outcome
The library is added as a development dependency, and the README identifies the test-runner setup as the next prerequisite.
Guide limitations
- This covers dependency installation and the stated prerequisite only; it does not provide a complete test-runner setup recipe.
Initialize an Ethereum mock in a test
Set up the README's basic EVM mock example in a test suite.
Before you start
- WEB3 Mock installed in the JavaScript project
- Jest, Cypress or Playwright set up before using the library
Steps
Import
mockfrom@depay/web3-mock.In the test's
beforeEach, callmock('ethereum').In the test, request
eth_chainIdandnet_versionfromwindow.ethereum.
Expected outcome
The example shows the mocked requests returning chain ID `0x1` and network version `1`.
Guide limitations
- The steps describe the README's basic Ethereum example, not a complete test configuration or a guarantee for other setups.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 October 2026
- Original website title
- DePayFi/web3-mock · Official homepage title · retained in its source language

