enzymejs / enzymejs/enzyme

Unmount and then wrapper.mount() again does not work properly

Open
#941 6 comments 3 reactions 0 assignees View on GitHub
API: mount bug help wanted question
Dominant language
JavaScript
Stars
19.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Enzyme: 2.8.2
React: 15.5.4

If we do wrapper.unmount(), and then wrapper.mount(), the component is not mounted properly. I can see an empty console output after mounting again.

Simple plain example as follows
```jsx
class Foo extends React.Component {
constructor(props) {
super(props);

}
render() {
return (


{this.props.id}

);
}
}

const wrapper = mount();

console.log("log before unmounting", wrapper.mount().debug()); //This logs the component properly

wrapper.unmount();

console.log("Log again after mounting", wrapper.mount().debug());//this logs empty component
```

Contributor guide

Open the contributing guide

Research direction

Start by running the provided React 15.5.4 and Enzyme 2.8.2 reproduction using mount, wrapper.unmount(), and wrapper.mount(). Trace the wrapper mount and unmount entry points to find why the second debug() is empty. Done means the component renders correctly after unmounting and mounting again, with a regression test covering the sequence.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.