如何解决我无法仅f h1标签 只需声明h1标签
spring.config.additional-location
****Test.tsx****
import * as React from 'react';
import Enzyme,{ shallow,mount } from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-16';
import Product from './Product';
import {checkProps} from './../../test/testUtils';
Enzyme.configure({adapter: new EnzymeAdapter()});
const defaultProps = {
Product:{
image : [],name : "test",sku : "test",price : [],}
};
const setup=(props={})=>{
const setupProps = {...defaultProps,...props};
return mount(<Product{...setupProps}/>)
};
test('dose not throw warning with expecet props',()=>{
checkProps(Product,defaultProps);
})
test('renders children when passed in',() => {
const wrapper = setup();
expect(wrapper.find('.h1')).toEqual(true);
});
我无法用酶测试玩笑来测试反应应用。因此在运行代码时断言失败。我需要对html标记进行断言,如果文件中存在标记,则断言为true或标记值;如果断言失败,则为false。
我有如下测试用例
- 只需要声明h1标签
- 只需要声明标题标签
我测试时,在所有三个测试中都遇到此错误
错误:
***Product.tsx***
const Product = (props: any) => {
const product = get(props,'products.items[0]') || null;
if (!product) return null;
const { image = {},name,sku,price = {} } = product;
return (
<ProductContext.Provider value={product}>
<div className='container pt-5 pt-5'>
<div className='columns'>
<div className='column is-5'>
<figure className='image is-1by1'>
<img
src={image.url}
alt={image.label}
className='fit-image product-image'
/>
</figure>
</div>
<div className='column is-7'>
<h1 className='is-size-3'>{name}</h1>
<div className='sku'>{sku}</div>
<div className='price'>$ {price.regularPrice.amount.value}</div>
<ProductForm>
<SimpleProductForm>
<div>
<Counter name='cart_items[0].quantity' />
<AddToCart />
</div>
</SimpleProductForm>
</ProductForm>
</div>
</div>
</div>
</ProductContext.Provider>
);
};
export const isServerSideRendered = true;
export default Product;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。