我正在使用 avoriaz 在 vuejs 中进行测试。这是我的测试和组件代码。
<template>
<v-container fluid class="login-container">
<div class="hyperlogo">
<center>
<img src='../../../assets/logo.png' height="100" width="100">
<p>HyperEmail</p>
<a>v0.11.1</a>
</center>
</div>
<v-layout row wrap>
<v-flex xs6 md4 offset-md4>
<v-card class="login-card">
<v-card-text class="login-text">
<v-text-field
v-on:focus="focusUser"
label="Username"
placeholder="Username"
class="mt-5"
v-model="username"
@keyup.enter.native="validateData"
v-bind:rules="[userNameError]"
></v-text-field>
<v-text-field
v-on:focus="focusPassword"
label="Password"
placeholder="Password"
v-model="password"
type="password"
v-on:keyup.enter.native="validateData"
v-bind:rules="[passwordError]"
></v-text-field>
</v-card-text>
<div @click="validateData" class="button-style">
<v-btn block primary light >Login</v-btn>
</div>
</v-card>
</v-flex>
<Error v-if="error" :text="error.msg" :onDestroy="resetError" />
</v-layout>
</v-container>
</template>
用于检测
import Login from '@/containers/views/login/Login.vue'
describe('Login.vue', () => {
it('checks text inside login component', () => {
const wrapper = mount(Login)
// let parent = wrapper.find('.hyperlogo')[0]
// expect(wrapper.contains('.hyperlogo')).to.equal(true)
if (wrapper.find('.hyperlogo')[0]) {
console.log('Yes it is there')
}
expect(wrapper.text()).to.equal('')
expect(wrapper.find('center')[0].is('center')).to.equal(true)
})
})
这里 wrapper.find 不起作用错误:-TypeError:无法读取未定义的属性'is' .. 谁能帮我解决这种类型的错误?