Open AlexNi245 opened 4 months ago
I had a similar error in Deno tests. I suspect the issue is that you're importing the library using ES Modules syntax (import
) but the library is not packaged to support that. I'm working on ESM support at https://github.com/jedisct1/libsodium.js/pull/337. You could try the build steps in that PR and see if it fixes your issue
Hello,
We've been working with libsodium-wrappers for a while, and it's an amazing library. We use it with functions in Node.js and React. Everything works fine when the libsodium-wrapper import is used within the app itself. However, we face some issues whenever we want to test anything that has a dependency on libsodium wrappers.
When I execute react-scripts test for the following code snippet.
I receive the following error
It seems that there is a problem with importing the underlying sodium library. As I understand it, the asynchronous behavior of libsodium is the reason why you have to await with _sodium.ready in the first place. However, when executed within the unit test, the error occurs during the import process itself.
Do you have an idea how I could fix this issue?
Thanks for your help!
Test command :
"test": "CI=true react-scripts test --transformIgnorePatterns \"node_modules/(?!dm3-lib-\\w*)/\""
Dependencies:
"ibsodium-wrappers": "^0.7.11"