synpress icon indicating copy to clipboard operation
synpress copied to clipboard

setupMetamask Errors with Electron

Open marcusnewton opened this issue 4 years ago • 5 comments

EDIT: I might just be dumb, this probably shouldn't work with Electron, right?

Getting the following issue only when running Electron.

The first issue I was getting was with the remote debugger

CypressError: `cy.task('setupMetamask')` failed with the following error:

> request to http://localhost:9222/json/version failed, reason: connect ECONNREFUSED 127.0.0.1:9222

which I fixed by exporting ELECTRON_EXTRA_LAUNCH_ARGS=--remote-debugging-port=9222. I'd suggest some way to handle this internally, or at least a line of documentation.

CypressError: `cy.task('setupMetamask')` failed with the following error:

> Cannot read property 'waitForTimeout' of undefined

It seems like await metamask.initialSetup({ secretWords, network, password }); from the plugin is being called before puppeteer has been been properly set up.

Note that I've configured metamask to use a custom network.

marcusnewton avatar Aug 09 '21 07:08 marcusnewton

Call stack

> Cannot read property 'waitForTimeout' of undefined

https://on.cypress.io/api/task

Because this error occurred during a `before all` hook we are skipping all of the remaining tests.
      at http://localhost:5000/__cypress/runner/cypress_runner.js:142397:19
      at tryCatcher (http://localhost:5000/__cypress/runner/cypress_runner.js:10798:23)
      at Promise._settlePromiseFromHandler (http://localhost:5000/__cypress/runner/cypress_runner.js:8733:31)
      at Promise._settlePromise (http://localhost:5000/__cypress/runner/cypress_runner.js:8790:18)
      at Promise._settlePromise0 (http://localhost:5000/__cypress/runner/cypress_runner.js:8835:10)
      at Promise._settlePromises (http://localhost:5000/__cypress/runner/cypress_runner.js:8911:18)
      at _drainQueueStep (http://localhost:5000/__cypress/runner/cypress_runner.js:5505:12)
      at _drainQueue (http://localhost:5000/__cypress/runner/cypress_runner.js:5498:9)
      at Async.../../node_modules/bluebird/js/release/async.js.Async._drainQueues (http://localhost:5000/__cypress/runner/cypress_runner.js:5514:5)
      at Async.drainQueues (http://localhost:5000/__cypress/runner/cypress_runner.js:5384:14)
  From Your Spec Code:
      at Context.eval (http://localhost:5000/__cypress/tests?p=node_modules/@synthetixio/synpress/support/index.js:6334:15)

marcusnewton avatar Aug 09 '21 07:08 marcusnewton

Yeah only getting 1 page showing up in assignWindows

http://localhost:5000/__/#/tests/integration/e2e/specs/example-spec.ts

I'd expect to see metamask extension popping up here. Although I'm still figuring out if Electron actually supports metamask in the first place.

marcusnewton avatar Aug 09 '21 07:08 marcusnewton

Hey @marcusnewton, after a quick look I can see that synpress could support Electron (as Electron supports loading Chrome extensions which would be metamask in this case), but it would require more coding before that. I don't think that it's going to work in current state, sorry.

drptbl avatar Aug 09 '21 19:08 drptbl

Ok thanks for confirming.

marcusnewton avatar Aug 10 '21 07:08 marcusnewton

As the error is similar, this may be helpful: #804

YakovL avatar Jul 11 '23 18:07 YakovL