我有一个负责注册的组件 Register.vue,为此我正在使用 jest 编写测试用例,这里我的疑问是如何为 P-tag 天气内容中存在的“在线图书购物”编写测试用例匹配与否,请帮我写一个测试用例并进行验证,请分享一些验证 HTML REGEX 模式的参考
Register.vue
<template>
<div class="main">
<div class="container">
<img id="side-img" src="../assets/sideImg.png" alt="notFound" />
<!-- i want to test weather this content is present or not -->
<p id="side-content">Online Book Shopping</p>
<form>
<div class="fullname">
<p>FullName</p>
<!-- for this input tag correct pattern is passed or not -->
<input type="name" class="namebox" required v-model="fullName" pattern="[A-Za-z]{3,12}">
</div>
</form>
</div>
</div>
</template>
Register.spec.js
import Register from '../../src/Pages/Register.vue';
import { createLocalVue, shallowMount} from '@vue/test-utils'
describe('Register.vue', ()=>{
let wrapper;
beforeEach(() => {
const localVue = createLocalVue();
wrapper = shallowMount(Register, localVue);
});
test('setup correctly', () => {
expect(true).toBe(true)
})
it('renders a vue instance', () => {
expect(shallowMount(Register).isVueInstance()).toBe(true);
})
it('has an image', () => {
expect(wrapper.contains('#side-img')).toBe(true);
});
// i stuck here weather the content is there or not
it('has online shopping content',()=>{
except(wrapper.text()).toContain('Online Book Shopping');
})
})