Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

TimeoutError: setupMetaMask doesn't work with Jest #297

Open
undefinedlol opened this issue Mar 16, 2023 · 4 comments
Open

TimeoutError: setupMetaMask doesn't work with Jest #297

undefinedlol opened this issue Mar 16, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@undefinedlol
Copy link

undefinedlol commented Mar 16, 2023

Describe the bug

import { launch, setupMetaMask } from '@chainsafe/dappeteer';

 browser = await launch({
    headless: true,
    automation: 'puppeteer',
    puppeteerOptions: {
      ignoreHTTPSErrors: true,
      args: ['--no-sandbox', `--window-size=1440,1024`],
      defaultViewport: {
        width: 1440,
        height: 1024,
      },
    },
  });

  metamask = await setupMetaMask(browser, {
    seed: 'xxxx',
    password: '123456',
    showTestNets: true,
  });

 page = await browser.newPage();
  await page.goto('http://localhost:8000/');

always get errors like

TimeoutError: Waiting for selector `[data-testid="onboarding-import-wallet"]` failed: Waiting failed: 20000ms exceeded

@chainsafe/dappeteer Version: 5.0.1
dappeteer: 19.6.3

@undefinedlol undefinedlol added the bug Something isn't working label Mar 16, 2023
@undefinedlol undefinedlol changed the title TimeoutError: work with Jest data-testid="onboarding-import-wallet" TimeoutError: setupMetaMask doesn't work with Jest Mar 16, 2023
@moshmage
Copy link

Same, but with [data-testid="metametrics-i-agree"] instead of [data-testid="onboarding-import-wallet"]

TimeoutError: Waiting for selector `[data-testid="metametrics-i-agree"]` failed: Waiting failed: 20000ms exceeded
    at Timeout.<anonymous> (C:\Users\moshm\WebstormProjects\wn-ui\node_modules\puppeteer-core\lib\cjs\puppeteer\common\WaitTask.js:72:37)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

I've also noticed that sometimes the first page that loads is not an "i agree" but instead the "import-wallet"

@mint-pz
Copy link

mint-pz commented Jul 13, 2023

Any solutions here? I got the same error as @moshmage

  • MetaMask extension version: v10.31.0,
  • @chainsafe/dappeteer: "^5.2.0"
  • puppeteer: "^20.8.1"

@mint-pz
Copy link

mint-pz commented Jul 21, 2023

Hey @undefinedlol, Can I know if you tested it with mocha? Did it work then?

@mint-pz
Copy link

mint-pz commented Aug 10, 2023

I don't get these issues anymore by using this config: https://github.com/ChainSafe/dappeteer/blob/master/docs/JEST.md#custom-example-without-preset

But you may get some others and here is my workaround:

1. environment.js

const NodeEnvironment = require('jest-environment-node').TestEnvironment

2. Have trouble starting metamask: #311 (comment)

System:

  • OS: macOS
  • NodeJs version: v18.14.2
  • dappeteer version: ^5.2.0
  • testing framework: jest
  • testing framework version: ^29.6.1
  • puppeteer version: ^21.0.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants