synpress icon indicating copy to clipboard operation
synpress copied to clipboard

[๐Ÿ› Bug]: 'Expected identifier but found "("'

Open PatrickAlphaC opened this issue 9 months ago โ€ข 1 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

4.0.4

Node.js version

v23.5.0

Operating system

macOS 15.3

Run mode

Playwright + Synpress (as plugin)

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'm trying to get through the playwright tutorial, and I'm having a hard time.

pnpm synpress e2e

The tutorial doesn't mention running this, but when I try to run:

 pnpm playwright test

I get the issue with the hashing. This issue says to make a hash, but I get this error trying to make a wallet hash:

% pnpm synpress e2e                     
โš ๏ธ The CLI is in alpha so expect breaking changes! โš ๏ธ

๐Ÿš€ Building the cache for wallet setup functions... ๐Ÿš€

Aborting...
Error: Transform failed with 1 error:
<stdin>:1:8: ERROR: Expected identifier but found "("
    at failureErrorWithLog (/Users/patrick/code/tsender-ui/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1651:15)
    at /Users/patrick/code/tsender-ui/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:849:29
    at responseCallbacks.<computed> (/Users/patrick/code/tsender-ui/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:704:9)
    at handleIncomingPacket (/Users/patrick/code/tsender-ui/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:764:9)
    at Socket.readFromStdout (/Users/patrick/code/tsender-ui/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:680:7)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [],
      pluginName: '',
      text: 'Expected identifier but found "("'
    }
  ],
  warnings: []
}

I'm a bit lost on how to progress.

What is your expected behavior?

I'm not sure, I think I expect to get a hash, and then be able to rename it.

How to reproduce the bug.

wallet.setup.ts:

import { defineWalletSetup } from '@synthetixio/synpress'
import { MetaMask } from '@synthetixio/synpress/playwright'

const SEED_PHRASE = 'test test test test test test test test test test test junk'
const PASSWORD = 'SynpressIsAwesomeNow!!!'

const setup = {
    ...defineWalletSetup(PASSWORD, async (context, walletPage) => {
        const metamask = new MetaMask(context, walletPage, PASSWORD);
        await metamask.importWallet(SEED_PHRASE);
    }),
    hash: 'wallet-hash',
};

export default setup;

example.test.ts

import { testWithSynpress } from '@synthetixio/synpress'
import { MetaMask, metaMaskFixtures } from '@synthetixio/synpress/playwright'
import basicSetup from './wallet.setup'

// Set up the test environment with Synpress and MetaMask fixtures, using the basic setup configuration
const test = testWithSynpress(metaMaskFixtures(basicSetup))

const { expect } = test

test('should connect wallet to the MetaMask Test Dapp', async ({ context, page, metamaskPage, extensionId }) => {
  await page.goto('http://127.0.0.1:3000')

  // Create a new MetaMask instance with the provided context, page, password, and extension ID
  const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId)

  // Click the connect button to initiate the wallet connection
  await page.locator('#connectButton').click()

  // Connect dApp to MetaMask
  await metamask.connectToDapp()

  // Verify that the correct account address is displayed
  await expect(page.locator('#accounts')).toHaveText('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266')

  // Click the button to get all connected accounts
  await page.locator('#getAccounts').click()

  // Verify that the correct account address is returned and displayed
  await expect(page.locator('#getAccountsResult')).toHaveText('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266')
})

And then just run pnpm synpress I guess?

Relevant log output


PatrickAlphaC avatar Feb 06 '25 03:02 PatrickAlphaC

Hey @PatrickAlphaC, can you try with node 22 and let me know if that solved the issue? Thanks.

If that didn't help, please try with synpress version 4.0.3.

drptbl avatar Feb 06 '25 08:02 drptbl