我无法仅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。

我有如下测试用例

  1. 只需要声明h1标签
  2. 只需要声明标题标签

我测试时,在所有三个测试中都遇到此错误

错误:

***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 (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...