javascript - Sinon stub error with local storage in karma tests (es6 + jspm) -
i trying stub setitem
, getitem
methods of window.localstorage
, experimenting issues can seen in screenshot:
the point don't know happens window.localstorage
object seems different depending on property. when time comes stub setitem
method, get
testing storage services localstorage "before each" hook "should return current name": typeerror: attempted wrap string property setitem function @ checkwrappedmethod (base/node_modules/sinon/pkg/sinon.js:1355:29) @ object.wrapmethod (base/node_modules/sinon/pkg/sinon.js:1398:21) @ object.stub (base/node_modules/sinon/pkg/sinon.js:3465:26) @ context.eval (client/js/common/services/storage/localstorage.spec.js!transpiled:30:14) @ object.invoke (base/client/jspm_packages/github/angular/bower-angular@1.5.1/angular.js:4628:19) @ context.workfn (base/client/jspm_packages/npm/angular-mocks@1.4.8/angular-mocks.js:2441:20) @ window.inject.angular.mock.inject (base/client/jspm_packages/npm/angular-mocks@1.4.8/angular-mocks.js:2413:37) @ context.eval (client/js/common/services/storage/localstorage.spec.js!transpiled:20:7) error: declaration location @ window.inject.angular.mock.inject (base/client/jspm_packages/npm/angular-mocks@1.4.8/angular-mocks.js:2412:25) @ context.eval (client/js/common/services/storage/localstorage.spec.js!transpiled:20:7)
i using jspm
client package/module manager. so, karma
config file is:
basepath: './', // frameworks use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jspm', 'mocha', 'chai-as-promised', 'chai', 'sinon'], // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['chrome'], // test results reporter use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['mocha'], // continuous integration mode // if true, karma captures browsers, runs tests , exits singlerun: true, // enable / disable colors in output (reporters , logs) colors: true, // list of files / patterns load in browser files: [], jspm: { // edit needs config: 'jspm.config.js', packages: 'client/jspm_packages', loadfiles: [ 'client/js/common/services/**/*.spec.js' ], servefiles: [ 'client/js/**/*.js', 'client/js/**/*.html', 'client/js/**/*.css' ], paths: { 'github:*': 'base/client/jspm_packages/github/*', 'npm:*': 'base/client/jspm_packages/npm/*', 'js/*': 'base/client/js/*' }, urlroot: './' }, proxies: { '/client': '/base/client' }, // list of files exclude exclude: [], // level of logging // possible values: config.log_disable || config.log_error || config.log_warn || config.log_info || config.log_debug loglevel: config.log_info, client: { captureconsole: true, mocha: { bail: false, // require: 'should' reporter: 'spec', ui: 'bdd' } }
the thing can if has had same issue and/or can provide hint come solution :-/
thanks!!!
Comments
Post a Comment