WalletConnect / modal

WalletConnectModal repository
https://lab-walletconnect-modal.pages.dev/
Apache License 2.0
18 stars 15 forks source link

[bug] Not able to run test #24

Closed mominnawaf closed 1 year ago

mominnawaf commented 1 year ago

Link to minimal reproducible example

/

Summary

I'm using ts-jest to run tests in my project. however, I'm getting this error.

Screenshot 2023-07-22 at 2 04 09 AM

Possible issue:: The error message indicates that Jest is encountering an unexpected token during parsing. This is often caused by the use of non-standard JavaScript syntax, or when Jest isn't configured to handle such syntax. In this case, the issue is occurring because Jest is trying to parse an ECMAScript module (i.e., a file with import and export statements), and Node.js, by default, treats files as CommonJS modules, not ECMAScript modules.

List of related npm package versions

@walletconnect/modal-sign-react

xzilja commented 1 year ago

Not much we can do here, my best advice would be to try jest's esm features described here https://jestjs.io/docs/ecmascript-modules or you can add build logic to compile to commonjs before tests. You might encounter further issues inside node as we use things like web-componennts, not sure how jest handles that. I know there are tools like vitest who handle this by running jsdom, maybe something like this is possible in jest as well.