Mocking clientHeight and scrollHeight in React + Enzyme for test
问题 We have a React component called ScrollContainer than calls a prop function when its content is scrolled to the bottom. Basically: componentDidMount() { const needsToScroll = this.container.clientHeight != this.container.scrollHeight const { handleUserDidScroll } = this.props if (needsToScroll) { this.container.addEventListener('scroll', this.handleScroll) } else { handleUserDidScroll() } } componentWillUnmount() { this.container.removeEventListener('scroll', this.handleScroll) } handleScroll