Back to top
Published on -
July 2, 2020
Written by:
Daenam Kim

Mock3 Released

We are pleased to announce the release of Mock3. The purpose of this tool is to aid developers by enabling automated UI tests.

Mock 3 Head

Photo by Javi on Unsplash

We are pleased to announce the release of Mock3. The purpose of this tool is to aid developers by enabling automated UI tests and thus speeding up the development of DApps. Let's take a closer look.

Here is the normal way to sign transactions.

TX with Web3

When signing transactions using MetaMask, developers will likely find themselves repeating this process over and over.

MultiBaas TX with Web3

Mock3 will remove this burden by automatically signing transactions on behalf of the developer.

TX with Mock3

Here is an example of how you might integrate Mock3 into your project. With this configuration, Mock3 would only be used when your application is being tested: in production, you would continue to use your existing web3 provider.


import { Mock3 } from 'mock3';

// You can use if branch for when you want to use Mock3
// In this example, it consider using Mock3 in NODE_ENV === 'test'
let web3;
if (NODE_ENV === 'test') {
  // Set JSON RPC using Infura, Ganache, Local, or your own
  // If you do not set, the default is Rinkeby
  web3 = new Mock3('YOUR.RPC.URL');

  // Set signers with private key array or single
  web3.setSigner(['0x3afe...', '0xf2f1...']);

  // You can also set a specific account like real behavior of selecting from MetaMask or just retrieve all accounts.
  web3.setAccountIndex(2);
} else {
  web3 = window.web3;
}

const accounts = await web3.listAccounts();




const accounts = await web3.listAccounts();

Hooray! 🎉🎉 Gone are the days of the MetaMask popup during testing.

MultiBaas TX with Mock3

For more information, please checkout my lighting talk at Devcon 5.Be happy with your DApp!