PillowPillow/ng2-webstorage

LocalStorageService does not have a strategy in my test environment?

Opened this issue · 3 comments

Versions (please complete the following information):

  • NgxWebstorage: 9.0.0
  • Angular: 13.1.2

I have a custom service which uses LocalStorageService from ngx-webstorage, which works fine in the "real world", but when I try to write a test that interacts with my service, my tests blow up with:

Cannot read properties of undefined (reading 'get') at LocalStorageService.retrieve (node_modules/ngx-webstorage/fesm2015/ngx-webstorage.mjs:74:23)

It appears in the test world this object is getting newed up without a strategy... what am I supposed to do to get this to "just work?" I tried adding NgxWebstorageModule.forRoot() to the imports for my Testbed, but that did not seem to make any difference.

I'm getting the same error. I try almost everything. without success? Does somebody have a clue about how to solve this?

TypeError: Cannot read properties of undefined (reading 'get')
    at LocalStorageService.retrieve (http://localhost:9876/_karma_webpack_/node_modules/ngx-webstorage/__ivy_ngcc__/fesm2015/ngx-webstorage.js:74:1)

I am getting same error, any update :/ ?

I have a same problem in 2024, ngx-webstorage 7.0.1 with angular 11, Any solution ?