在Jest中编写单元测试时如何检查组件

时间:2019-05-08 10:19:51

标签: javascript reactjs typescript jestjs

我的单元测试失败了(最后第二行)。在测试实例化后,如何检查AnalysisList组件以查找其中的内容?

            test("should be one list", () => {
            const component = mount(<ValueAnalysisCard
                frequentValues={[]}
                rareValues={[]}
                objectTypeInstanceCount={objectTypeInstanceCount}
                derived={false}
                onSearch={onSearch} />);

            expect(component.find(AnalysisList)).toHaveLength(1);
            // expect(component.find(ListItem)).toHaveLength(1); // FAIL
            expect(component.find(LinkText)).toHaveLength(0);

0 个答案:

没有答案