Skip to content

Please some information about find() as a snapshot to docs #2367

@Adrianjewell91

Description

@Adrianjewell91

Current behavior

Hello, I would simply like to request that the documentation for find() (https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/find.html) be updated to reflect its snapshot-nature. For example, in a situation where clicking a button updates state under the hood...

   // some set up code goes here. 

    const deleteButton = wrapper.find('[data-enzyme-id="someid"]').first();
    deleteButton.simulate('click');

    expect(wrapper.find("#modal").first().props().isOpen).toBe(true)

the above code will work, but the below will not:

    const modals = wrapper.find("#modal");
    const deleteButton = wrapper.find('[data-enzyme-id="someid"]').first();
    deleteButton.simulate('click');

    expect(modals.first().props().isOpen).toBe(true)

Presumably, this is because the objects that are returned by find() do not reflect the actual DOM tree, but a snapshot thereof.

It would be great to see this mentioned briefly in the documentation. Please suggest a way to explain this in a documentation-appropriate manner. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions