Javascript Jest-事件、下拉列表的写作测试

Javascript Jest-事件、下拉列表的写作测试,javascript,reactjs,jestjs,Javascript,Reactjs,Jestjs,我正在尝试编写一个jest测试,它将检查组成表中一行的组件 像这样的 测试用例是这样的 --如果日期选择器已更改。将调用以更新下拉框。 --如果下拉框中的选项已更改,将清除下拉框 describe('row component module', () => { test('if date has changed and after the dropdown options replenished if different clear dropdown', done

我正在尝试编写一个jest测试,它将检查组成表中一行的组件

像这样的

测试用例是这样的 --如果日期选择器已更改。将调用以更新下拉框。 --如果下拉框中的选项已更改,将清除下拉框

  describe('row component module', () => {
        test('if date has changed and after the dropdown options replenished if different clear dropdown', done => {
            const DateComponent = mount(<DatePicker />),
                dateInput = DateComponent.find("input[type='text']");

           DateComponent.instance().handleChange = jest.fn();

            dateInput.simulate('change', {target: { value: "2018-01-04" }});
            done();

            expect(DateComponent.instance().handleChange.mock.calls.length).toBe(1);


            expect(wrapper.render().find('select [selected]').val()).to.equal('-');

        });
    });
description('行组件模块',()=>{
测试('如果日期已更改,并且如果不同的清除下拉菜单,则在下拉菜单选项补充后',完成=>{
const DateComponent=mount(),
dateInput=DateComponent.find(“输入[type='text']”);
DateComponent.instance().handleChange=jest.fn();
模拟('change',{target:{value:'2018-01-04'});
完成();
expect(DateComponent.instance().handleChange.mock.calls.length).toBe(1);
expect(wrapper.render().find('select[selected]').val().to.equal('-');
});
});

您的意思是要解决问题吗?如何记录控制台日志以便知道您的元素存在于包装器中?这里我只得到了伪用例-项目中的测试很少,没有以前那么复杂。考虑到您使用的是酶测试实用程序,您应该能够调用
.debug()
方法:console.log(DateComponent.debug());查看文档()