Reactjs 如何在jest和Ezyme中测试输入类型

Reactjs 如何在jest和Ezyme中测试输入类型,reactjs,testing,jestjs,enzyme,input-type-file,Reactjs,Testing,Jestjs,Enzyme,Input Type File,在一个表单中,我想测试我是否有两个数字类型的输入,两个文本输入和一个复选框输入。如何使用find()(或其他方法)方法获取要比较的输入类型 看来我找到了办法 const wrapper = shallow(<Login/>); const type = wrapper.find('input').map((node) =>node.props().type); const phone = type.filter((e)=>e === 'number').

在一个表单中,我想测试我是否有两个数字类型的输入,两个文本输入和一个复选框输入。如何使用
find()
(或其他方法)方法获取要比较的输入类型

看来我找到了办法

 const wrapper = shallow(<Login/>);
    const type = wrapper.find('input').map((node) =>node.props().type);
    const phone = type.filter((e)=>e === 'number').length===1;
    const password = type.filter((e)=>e === 'password').length===1;
    const checkbox = type.filter((e)=>e === 'checkbox').length===2;
    expect(phone).toBeTruthy();
    expect(password).toBeTruthy();
    expect(checkbox).toBeTruthy();
const wrapper=shallow();
const type=wrapper.find('input').map((node)=>node.props().type);
const phone=type.filter((e)=>e==number')。长度==1;
const password=type.filter((e)=>e=='password')。长度==1;
const checkbox=type.filter((e)=>e==checkbox')。长度==2;
expect(phone.toBeTruthy();
expect(password.toBeTruthy();
expect(复选框).toBeTruthy();
还有更好的办法吗