Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to complete setupMetamask. #278

Closed
cinjon opened this issue Nov 16, 2021 · 5 comments
Closed

Failing to complete setupMetamask. #278

cinjon opened this issue Nov 16, 2021 · 5 comments

Comments

@cinjon
Copy link

cinjon commented Nov 16, 2021

I have the following simple test. I've also set it up almost exactly as in the instructions. However, synpress is failing with the following error:

cy.task('setupMetamask') failed with the following error:
> waiting for function failed: timeout 30000ms exceeded
Because this error occurred during a before all hook we are skipping the remaining tests in the current suite:

Any idea what's going on?

describe('mint on the app.', () => {
    before(() => {
      cy.setupMetamask(
        'test test test test test test test test test test test junk',
        'localhost',
        'Tester@1234',
      ).then(setupFinished => {
        expect(setupFinished).to.be.true;
      });
      cy.visit('/')
    })

    it('visits the homepage and logs into web3sso.', () => {      
      cy.visit('/')
      cy.wait(2000)
      cy.get('#web3SSO').contains("Connect").click()
      cy.wait(2000) // wait 2s.
      cy.get('.web3modal-provider-name div').contains("MetaMask").click()
      cy.wait(2000) // wait 2s.
      cy.get('#headlessui-menu-button-3').should('have.text', '0xf39F');
    })
})
@cinjon
Copy link
Author

cinjon commented Nov 16, 2021

This is true even if I just copy-paste in https://github.com/Synthetixio/synpress/blob/master/tests/e2e/specs/metamask-spec.js and run it. It always fails to complete the cy.task('setupMetamask') function.

@raparri01
Copy link

I had a similar issue and it took a few rounds of debugging to get this base test case passing. Here's what I noticed / changed:

  1. The tsconfig.js in my /tests/e2e was not being picked up by the typescript compiler so I had to make debugging changes to the tsconfig in my project root
  2. The application running at localhost didn't accept connections to rpc's with chainId: 42 (kovan) so I made sure it was supported by my rpc connector
  3. I was not targeting the right ecmascript target. Changing the target from es5 to esnext got the tests working
  4. Needed to set importHelpers in my compilerOptions to true
  5. Needed to install tslib and set it's path in the paths object of tsconfig

Hope these help you!

@cinjon
Copy link
Author

cinjon commented Nov 26, 2021

Thanks for helping @raparri01 . I switched to using dappeteer (with puppet) and it worked more smoothly.

@cinjon cinjon closed this as completed Nov 26, 2021
@drptbl
Copy link
Member

drptbl commented Nov 26, 2021

@cinjon @raparri01 sorry for late response.

You are missing SKIP_METAMASK_SETUP=true if you want to use your custom setupMetamask() function in tests. In general, you shouldn't be really using it this way if not required.

I recommend sticking with default method which requires you to set environmental variables mentioned in the readme to make it work (like SECRET_WORDS='test test' or PRIVATE_KEY=test). Then everything is handled automatically for you every test and you don't have to repeat it yourself in your tests.

@4ortytwo
Copy link

4ortytwo commented Jun 3, 2022

@drptbl where do you have to set these environment variables?

edit:

Nevermind! Had to set those before I ran the command:

PRIVATE_KEY="" NETWORK_NAME=rinkeby yarn synpress run

Got confused because in the readme, I saw -e and thought I have to pass the envs after the command itself, and it wasn't working for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants