0

I'm wondering what the best way to test the entire stack of a dapp is?

From UI -> to wallet connection -> web3.js and interacting with the smart contract?

In web2 we could just use something like puppeteer, but extensions can't run inside headless chrome. So I'm not sure the best way to go about automating full workflows with Metamask.

If there is a framework or service for this, I'd love to know, as I'd rather not roll my own solution as described here

If you have any suggestions I would love to hear them!

2 Answers 2

0

This should solve your problem!

https://github.com/Synthetixio/synpress

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – thefett
    Mar 15, 2022 at 14:42
  • Yes! I discovered synpress--very cool repo! Mar 16, 2022 at 22:25
0

You can test Metamask interactions with Synpress, e.g check if you can connect with the metamask wallet from your DApp with the following test case:

describe('Test User Login', () => {

    it('Connects with Metamask', () => {
       cy.visit('http://localhost:3000')
        // find "Connect Wallet" button and click it
        cy.contains('Connect Wallet').click();
        // assuming there is only metamask popping up 
        // always important to switch between metamask and 
        // cypress window
        cy.switchToMetamaskWindow();
        // connect to dapp
        cy.acceptMetamaskAccess().should("be.true");
        cy.confirmMetamaskSignatureRequest();
        // switch back to cypress window (your dApp)
        cy.switchToCypressWindow();
        // check UI change
        cy.contains('...').should('be.visible');
    })
  })

For more details on how to use Synpress check this tutorial.

https://medium.com/coinmonks/test-e2e-login-to-dapp-with-metamask-with-synpress-5248dd1f17c1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.