ChainSafe / dappeteer

[DEPRECATED]🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
Other
490 stars 152 forks source link

dAppeteer with Jest not working in Headless mode #270

Open asimpk opened 1 year ago

asimpk commented 1 year ago

Describe the bug I am facing an issue while running dAppeteer with jest in headless mode, in setup.js launch runs successfully but setupMetaMask doesn't work properly, similar issue is dappeteer.bootstrap() runs perfectly without headless mode

To Reproduce Steps to reproduce the behavior:

  1. Follow the doc to run DAppteer with Jest https://github.com/ChainSafe/dappeteer/blob/master/docs/JEST.md
  2. const browser = await launch(puppeteer, PUPPETEER_CONFIG), add the Headless: true option, BTW doc needs to be updated.
  3. run the tests

Logs

Determining test suites to run...
        Running tests on MetaMask version v10.23.0
        Flask version: false,
        Headless: true

Expected behavior Tests should run, and logs should be seen to get show progress or give error

System:

Additional context A similar bug is seen when we run script without jest from as in README.md; https://github.com/ChainSafe/dappeteer const { metaMask, browser } = await dappeteer.bootstrap({ browser: "chrome", headless: true });

BeroBurny commented 1 year ago

Thanks for pointing issue. Can you tell me which automation framework you use and what version?

asimpk commented 1 year ago

Sorry, I'm not using any framework right now, I first tried to use synpress https://github.com/Synthetixio/synpress but not using it and any other

BeroBurny commented 1 year ago

try to install playwright or puppeteer and then run tests

asimpk commented 1 year ago

try to install playwright or puppeteer and then run tests

Yeah I'm using "puppeteer": "^19.6.2", as that, was the requirement for setup, tests running successfully but only when not in headless mode

BeroBurny commented 1 year ago

it is confirmed that there is a bug, for now, the workaround is to use the playwright


observed notes

https://github.com/ChainSafe/dappeteer/blob/ee4a5136250a4b64d8045233227b9926cb203e75/src/setup/setupMetaMask.ts#L96-L113 for some reason, targetcreated is never triggered in puppeteer

cc @irubido @Lykhoyda

BeroBurny commented 1 year ago

simple repo for reproducing issue https://github.com/BeroBurny/dappeteer-jest

asimpk commented 1 year ago

it is confirmed that there is a bug, for now, the workaround is to use the playwright

observed notes

https://github.com/ChainSafe/dappeteer/blob/ee4a5136250a4b64d8045233227b9926cb203e75/src/setup/setupMetaMask.ts#L96-L113

for some reason, targetcreated is never triggered in puppeteer cc @irubido @Lykhoyda

Thanks @BeroBurny , by using playwright, it throws an exception from environment.js if (!wsEndpoint) throw new Error('wsEndpoint not found'); but in the case of puppeteer we get browser.wsEndpoint(), ws://127.0.0.1:50927/devtools/browser/{key}

Lykhoyda commented 1 year ago

@asimpk the issue is due to the puppeteer version. Please set version 14.0.0 in package.json until we update it on the dappeteer side