synpress icon indicating copy to clipboard operation
synpress copied to clipboard

[๐Ÿ› Bug]: Synpress 3.7.3 throws a TypeError 'Cannot read properties of undefined' while installing Metamask extension

Open r-komarov opened this issue 1 year ago โ€ข 4 comments

๐Ÿ”Ž Have you searched existing issues to avoid duplicates?

  • [X] I have made sure that my issue is not a duplicate.

๐Ÿงช Have you tested your code using latest version of Synpress?

๐Ÿ’ก Are you able to provide enough information to be able to reproduce your issue locally?

  • [X] I can provide enough details to reproduce my issue on local environment.

Synpress version

3.7.3

Node.js version

20.10.0

Operating system

Windows 11

Run mode

Synpress (standalone)

CI platform (if applicable)

No response

Are you running your tests inside docker? (if applicable)

  • [ ] This issue could be related to docker.

What happened?

I have a Playwright+Sypress TypeScript test that installs Metamask into Chrome and logs in to a website. Used metamask fixtures from Sypress examples https://github.com/synpress-io/synpress-examples/tree/master/playwright , almost exactly copypasted the example fixture into my test adding just the seed phrase and password.

Playwright opens Chromium, goes to extensions blinks for a second, then immediately crashes with an exception:

TypeError: Cannot read properties of undefined (reading 'waitForTimeout')

at ..\fixtures.ts:46

44 | 45 | // setup metamask

46 | await initialSetup(chromium, { | ^ 47 | secretWordsOrPrivateKey: 48 | "test test test test test test test test test test test junk", 49 | network: "optimism",

at Object.fixBlankPage (C:\Users\rkoma\Documents\Work\Lisa\Src\synpress\synpress_373-examples\playwright\isolated-state\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]_@[email protected]__b_kejanbpmtdrkmqkoz7n3cj7t74\node_modules\@synthetixio\synpress\commands\playwright.js:399:16)
at initialSetup (C:\Users\rkoma\Documents\Work\Lisa\Src\synpress\synpress_373-examples\playwright\isolated-state\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]_@[email protected]__b_kejanbpmtdrkmqkoz7n3cj7t74\node_modules\@synthetixio\synpress\commands\metamask.js:1526:22)

If debugged through Visual Studio code -> Debug test it goes through the process and installs the extension, apparently fixBlankPage crashes or needs more time.

Everything was working fine about 3 weeks, then after a break ran the test on 12-Aug. Happens on Synpress 3.7.3 and 3.7.2-beta3.

What is your expected behavior?

Metamask extension installed

How to reproduce the bug.

  1. Download examples from https://github.com/synpress-io/synpress-examples/tree/master
  2. Add a new test into tests folder:

import { test, expect } from "../fixtures"; import * as metamask from "@synthetixio/synpress/commands/metamask";

const LisaUrl = process.env.PLAYWRIGHT_TEST_BASE_URL || 'https://dev.lisafoundation.com/'; const LisaMainPageTitle = 'Explore - LISA Foundation'; const extendedTimeout = 30000; // 30 sec - longer timeout for slow operations const metamaskWallet = ''; const metamaskUserName = 'User name';

test('Metamask login', async ({ page }) => { await page.goto(LisaUrl); await page.getByRole('button', { name: 'Sign in' }).click(); await page.locator('div:nth-child(3) > button').first().click(); await metamask.acceptAccess(); await expect(page.getByText(metamaskUserName)).toBeVisible({ timeout: extendedTimeout }); });

  1. Run the test in chromium (add a shortcut command into package.json if wanted) npx playwright test --project=chromium -g "Metamask login"

Relevant log output

C:\Src\synpress\synpress_373-examples\playwright\isolated-state>pnpm metamasktest

> @synpress-io/[email protected] metamasktest C:\Src\synpress\synpress_373-examples\playwright\isolated-state
> playwright test --project=chromium -g "Metamask login"


Running 1 test using 1 worker
  1) [chromium] โ€บ Lisa-metamask-login.spec.ts:14:5 โ€บ Metamask login โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

    TypeError: Cannot read properties of undefined (reading 'waitForTimeout')

       at ..\fixtures.ts:46

      44 |
      45 |     // setup metamask
    > 46 |     await initialSetup(chromium, {
         |     ^
      47 |       secretWordsOrPrivateKey:
      48 |         "test test test test test test test test test test test junk",
      49 |       network: "optimism",

        at Object.fixBlankPage (C:\Src\synpress\synpress_373-examples\playwright\isolated-state\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]_@[email protected]__b_kejanbpmtdrkmqkoz7n3cj7t74\node_modules\@synthetixio\synpress\commands\playwright.js:399:16)
        at initialSetup (C:\Src\synpress\synpress_373-examples\playwright\isolated-state\node_modules\.pnpm\@[email protected]_@[email protected]_@[email protected]_@[email protected]__b_kejanbpmtdrkmqkoz7n3cj7t74\node_modules\@synthetixio\synpress\commands\metamask.js:1526:22)
        at Object.context (C:\Src\synpress\synpress_373-examples\playwright\isolated-state\fixtures.ts:46:5)

  1 failed
    [chromium] โ€บ Lisa-metamask-login.spec.ts:14:5 โ€บ Metamask login โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

r-komarov avatar Aug 16 '24 03:08 r-komarov