Wisembly / basil.js

The missing Javascript smart persistent layer
https://wisembly.github.io/basil.js
Other
1.98k stars 62 forks source link

Doesn't work with Jest? #44

Closed reintroducing closed 6 years ago

reintroducing commented 7 years ago

Hello, I don't know if this is the right place for this but I was hoping you could point me in the right direction. I have a thin wrapper around basil called StorageUtils (it just extracts the usage into a module that I prefer basically but uses Basil under the hood). When I test StorageUtils in mocha it works perfectly fine.

I'm now converting my tests to use Jest and it no longer works. Even something as simple as this returns null (not even a real test):

describe('Storage utils', () => {
    StorageUtils.set('name', 'Jest');
    console.log('~~~~', StorageUtils.get('name'));
});

I am at a loss as to why this is happening but was hoping maybe it would trigger something in your mind to help lead me down the right path. Any help would be greatly appreciated.

guillaumepotier commented 7 years ago

Hi,

If it works perfectly in Mocha but not in Jest, I suggest to look deeper Jest to understand how it works. Problem should be there ;)

Could you provide a jsfiddl or jsbin with Jest + basil to run and test online? Maybe Jest is preventing access to window or document on which basil rely to access cookies, storages.. ?

Best