Issue
When testing Javascript SDK browser mode using Jest, it fails with the following error:
Shared Client not supported by the storage mechanism. Create isolated instances in stead
Root cause
When using Jest for testing applications, Jest runs in NodeJS by default, and NodeJS does not support shared clients, which is why it detects the storage does not have that function.
It is not possible to overwrite that method from the outside.
Solution
To resolve this, we can instruct Jest to explicitly resolve to browser by setting the config in jest options. For example, when using package.json we can add the flag below
{
"name": "MYAPP",
"version": "X.X.X",
....
"jest": {
"browser": true
}
...
}
Check out the Jest doc link for more information.
Comments
0 comments
Please sign in to leave a comment.