synpress icon indicating copy to clipboard operation
synpress copied to clipboard

[๐Ÿ› Bug]: `cy.importMetamaskAccount()` timeout on duplicate account

Open MichalLytek opened this issue 1 year ago โ€ข 1 comments

๐Ÿ”Ž Have you searched existing issues to avoid duplicates?

  • [X] I have made sure that my issue is not a duplicate.

๐Ÿงช Have you tested your code using latest version of Synpress?

๐Ÿ’ก Are you able to provide enough information to be able to reproduce your issue locally?

  • [X] I can provide enough details to reproduce my issue on local environment.

Synpress version

3.7.2-beta.7

Node.js version

18.18.0

Operating system

Ubuntu 20.04

Run mode

Cypress + Synpress (as plugin)

CI platform (if applicable)

No response

Are you running your tests inside docker? (if applicable)

  • [ ] This issue could be related to docker.

What happened?

When I run my test suite for the first time, the cy.importMetamaskAccount() command works fine.

When I re-run the test, the cy.importMetamaskAccount() command hangs and cause cypress timeout:

cy.task('importMetamaskAccount') failed with the following error:



> page.waitForNavigation: Timeout 30000ms exceeded.

=========================== logs ===========================

waiting for navigation until "load"

============================================================

If I check the metamask extension window, it stucks on the duplicate account error:

image

It's caused by the fact that the metamask extension has a shared state between the test runs. Even cypress/browser restart does not change it, only manually removing the extension from the chrome browser.

What is your expected behavior?

The command should check if the error is displayed, then click cancel and return false from the command.

This way we can detect that the account was already imported and we can do cy.switchMetamaskAccount() to activate the account on which behalf we want to operate in our dApp.

How to reproduce the bug.

const walletKey = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';

describe('bug reproduction', () => {
  it('crashes on subsequent `importMetamaskAccount` calls', () => {
    cy.importMetamaskAccount(walletKey);
  });
});

Relevant log output

No response

MichalLytek avatar Oct 03 '23 12:10 MichalLytek

Also experiencing this. Did you ever find a workaround @MichalLytek?

mliu avatar Apr 25 '24 13:04 mliu