Skip to content

[1.0.0-beta.0] Cannot assert descendant not present #207

@ZebraFlesh

Description

@ZebraFlesh

Given this component and the following tests:

 const Test = ({ className, shouldDisplay }) => shouldDisplay ? <div className={className}></div> : null;
const thing = mount(<Test className="foo" shouldDisplay={true} />);
expect(thing).to.have.descendants('.foo');

const thing2 = mount(<Test className="foo" shouldDisplay={false} />);
expect(thing2).to.not.have.descendants('.foo');

The not descendants test on thing2 fails with the message: AssertionError: expected <Test /> not to have descendants '.foo' HTML: Not available due to: Cannot read property 'outerHTML' of null

Switching the last expectation to the following:
expect(thing2.find('.foo')).to.not.exist;

it still fails with the same error: AssertionError: expected the node in <Test /> not to exist HTML: Not available due to: Cannot read property 'outerHTML' of null

This is with enzyme 3.2.0 and react 15.4.2. With enzyme 2.x and the pre-1.0 releases, these tests worked just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions