browserify - Running Karma tests with VueJS single file component using Vueify -


i trying run unit tests karma. have calendar.tests.js file looks lot this:

import { handleselectday } '../components/calendar/index.vue' describe('calendar', () => {   describe('handleselectday', () => {     const data = {};      describe('updates data', () => {       it('should set selectedday new id', () => {         handleselectday('id');         expect(data.dayselected).to.equal('id');       });     });   }); }); 

when run test karma following: typeerror: (0 , _index.handleselectday) not function not function

my karma.conf.js looks like:

module.exports = function (config) {   config.set({      frameworks: ['browserify', 'mocha'],     files: ['static/js/apps/futurehours/test/calender.tests.js'],     preprocessors: {       'static/js/apps/**/test/*.js': ['browserify']     },     browsers: ['chrome'],     loglevel: 'log_debug',      plugins: [       'karma-mocha',       'karma-browserify',       'karma-chrome-launcher',       'karma-spec-reporter'     ],      browserify: {       debug: true,       transform: [['babelify', { presets: ['env'] }], 'vueify']     }   }) } 

how can karma play nice vuejs single file components?

the problem can't have named export .vue component. instead, methods used in component have accessed via component object in unit test. functions used outside component's methods, should live in own es module make unit testing them easier.


Comments