0
我试图用Karma运行我的单元测试。我有calendar.tests.js
文件看起来很像这样的:使用Vueify运行VueJS单个文件组件的Karma测试
import { handleSelectDay } from '../components/Calendar/index.vue'
describe('Calendar',() => {
describe('handleSelectDay',() => {
const data = {};
describe('updates data',() => {
it('should set the selectedDay to a new id',() => {
handleSelectDay('id');
expect(data.daySelected).to.equal('id');
});
});
});
});
当我运行这个测试与噶我得到如下:TypeError: (0 , _index.handleSelectDay) is not a function is not a function
我karma.conf.js样子:
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']
}
})
}
如何获得Karma与VueJS单个文件组件搭配使用?