Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest raises Cannot read properties of undefined (reading 'sodium') #1390

Open
fboucquez opened this issue Mar 13, 2023 · 3 comments
Open

Jest raises Cannot read properties of undefined (reading 'sodium') #1390

fboucquez opened this issue Mar 13, 2023 · 3 comments

Comments

@fboucquez
Copy link

Hi team, jest is raising this error when trying to use cosmojs that depends on libsodium-wrappers

Minimal example:

import Tendermint34Client from '@cosmjs/tendermint-rpc'

test('Tendermint34Client', () => {
  console.log(Tendermint34Client)
})


Any hint on how to fix it?

@webmaster128
Copy link
Member

Which error do you get?

The import needs to look like this

import { Tendermint34Client } from '@cosmjs/tendermint-rpc'

@fboucquez
Copy link
Author

My mistake, it's the same error. The problem is loading the libsodium library. Somebody else also had that error.

https://stackoverflow.com/questions/73088159/importing-libsodium-wrappers-in-jest-throws-the-error-cannot-read-properties-of

My current workaround is chaging e.sodium.onload => e?.sodium.onload in the node_modules's libsodium

@webmaster128
Copy link
Member

Any chance this is related to #1429? Or something completely different?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants