Jest/Enzyme ShallowWrapper is empty when creating Snapshot

前端 未结 8 901
醉话见心
醉话见心 2020-12-28 15:25

So I\'m writing a test for my Item component and I tried to render the ItemCard component and then use that wrapper to create a snapshot but it returns an empty

8条回答
  •  Happy的楠姐
    2020-12-28 16:02

    Perhaps a bit late, but i managed to get a solution of this problem by using https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/getElement.html

    describe("Button", () => {
      it("should render basic button correctly", () => {
        const tree = shallow();
        expect(tree.getElement()).toMatchSnapshot();
      });
    });
    

    this work on Jest 26.5.3 and enzyme 3.10.5

提交回复
热议问题