enzymejs / enzyme-matchers

Jasmine/Jest assertions for enzyme
MIT License
892 stars 116 forks source link

toBeEmptyRender Doesn't Work for Nested Components #281

Closed LandonSchropp closed 5 years ago

LandonSchropp commented 5 years ago

I have two components, one nested inside the other:

class Example extends React.Component {

  render() {
    return null;
  }
}

class ExampleWrapper extends React.Component {

  render() {
    return <Example />;
  }
}

I'm trying to assert that the outer element results in a null render:

it("is an empty render", () => {
  let component = mount(<ExampleWrapper />);
  expect(component).toBeEmptyRender();
});

However, this test fails with the following error:'

    Expected <ExampleWrapper> to be empty render (false or null), but it was not
    Found Nodes HTML output: null

      24 | it("is an empty render", () => {
      25 |   let component = mount(<ExampleWrapper />);
    > 26 |   expect(component).toBeEmptyRender();
         |                     ^
      27 | });
LandonSchropp commented 5 years ago

I dug into this a bit more and I think the problem is in Enzyme (airbnb/enzyme#1866). I'm going to close this here.