我目前在单元测试中遇到此错误,我在模拟表单提交后找不到具有特定类名的元素:
检查元素中的HTML元素:
<div class="ant-form-item-control has-error">
<input type="text" class="ant-input ant-input-lg addSiteBasics_businessName" value="" placeholder="English Business Name" id="businessName">
<div class="ant-form-explain">Please add the name of your business.</div>
</div>
测试脚本:
describe('given business name is empty', () => {
it('display error if business name empty', () => {
const form = wrapper.find('form').first();
form.simulate('submit');
expect(wrapper.find('div.has-error #businessName').exists()).toBe(true);
})
});
这是我终端中显示的错误:
期望(收到).toBe(预期)
Expected value to be (using ===): true Received: false