我创建一个新的vue项目并安装jest等 . 之后我安装bootstrap-vue(npm包)并且jest失败并出现错误:测试套件无法运行
... \ node_modules \ bootstrap-vue \ es \ components \ form-select \ form-select.js:1({“Object . ”:function(module,exports,require,__ dirname,__ filename,global,jest){从'../../mixins/id'导入idMixin; ^^^^^^
我的vue文件:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<b-select v-model="selected" :options="options">
</b-select>
</div>
</template>
<script>
import BSelect from '../../node_modules/bootstrap-vue/es/components/form-select/form-select'
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Hellow word',
selected: null,
options: [
{ value: null, text: 'Please select an option' },
{ value: 'a', text: 'This is First option' },
{ value: 'b', text: 'Selected Option' },
{ value: {'C': '3PO'}, text: 'This is an option with object value' },
{ value: 'd', text: 'This one is disabled', disabled: true }
]
}
},
components: {
'b-select': BSelect
}
}
</script>
我的测试文件是默认测试:
import Vue from 'vue'
import HelloWorld from '@/components/HelloWorld'
describe('HelloWorld.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(HelloWorld)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.toEqual('Hellow word')
})
})