Synthetixio / synpress

Synpress is e2e testing framework based on Cypress.io and playwright with support for metamask.
https://synpress.io
606 stars 193 forks source link

setupMetamask Errors with Electron #188

Open marcusnewton opened 3 years ago

marcusnewton commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

drptbl commented 3 years ago

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.

marcusnewton commented 3 years ago

Ok thanks for confirming.

YakovL commented 1 year ago

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