marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.02k stars 1.33k forks source link

v2 failed in PhantomJS #220

Closed rokoroku closed 7 years ago

rokoroku commented 7 years ago

prior to v2, my tests are all good. but after upgrading to v2, store related tests are all broken now.

using karma@1.5, karma-phantomjs-launcher@1.0.4, phantomjs@2.1.1 and webpack@2.2.1

is this problem related to phantomJS's missing support for localstorage?

example output:

FAILED TESTS:
  AuthStore
    ✖ "before all" hook
      PhantomJS 2.1.1 (Mac OS X 0.0.0)
    undefined is not a constructor (evaluating '__WEBPACK_IMPORTED_MODULE_2_app_utils__["a" /* LocalStorage */].clear()')
    test/app/stores/AuthStore.spec.ts:108701:78

    ✖ "after all" hook
      PhantomJS 2.1.1 (Mac OS X 0.0.0)
    undefined is not a constructor (evaluating '__WEBPACK_IMPORTED_MODULE_2_app_utils__["a" /* LocalStorage */].clear()')
    test/app/stores/AuthStore.spec.ts:108704:78
rokoroku commented 7 years ago

It resolves with using require('store/dist/store.everything.min') or require('store/dist/store.legacy.min')

Why don't we use main entry in package.json to direct distribution build?, or we can add browser entry to the package.json. It will prevent such situations.

rokoroku commented 7 years ago

Found that it was caused by deprecated clear() method. Changing it to clearAll() resolves the issues :)

BelinChung commented 6 years ago

store.js failed in PhantomJS@2.1 Here is the error log

PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  TypeError: undefined is not a function (evaluating 'this._deserialize(data, optionalDefaultValue)')
  at webpack:///node_modules/store/src/store-engine.js:23:0 <- index.js:154778

Is there any way to solve the problem?