是否有任何示例如何在vue
中编写测试用例? 点击事件无效。
App.vue中的模板
<template>
<div class="main">
<textarea v-model="input" id="input" rows="3" placeholder="Please entry colors, eg: '#000','#fff' or ['#000', '#fff']"></textarea>
<button type="button" class="btn btn-primary parse" @click="parse">Go!</button>
<ul>
<li v-for="color in colors">
<span v-bind:style="{ background: color}"></span>
{{color}}
<li>
</ul>
业力测试
describe('App.vue', () => {
it('should render correct color', () => {
const vm = new Vue({
template: "<div><app></app></div>",
components: {
App
}
}).$mount()
console.log(vm.$el)
vm.input = '#333, #444'
vm.$el.querySelector('.btn').click()
expect(vm.$el.querySelector('ul li:eq(0) span').style.background).toBe('#333')
})
})