Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit 6a489d9 broke unit tests #7

Open
AlwaysMoreHats opened this issue Aug 11, 2015 · 2 comments
Open

Commit 6a489d9 broke unit tests #7

AlwaysMoreHats opened this issue Aug 11, 2015 · 2 comments

Comments

@AlwaysMoreHats
Copy link

Unit tests have been broken since this commit.

Broken with error TypeError: Cannot read property '1' of undefined in getElementHeight, line 61

@AlwaysMoreHats
Copy link
Author

Adding in jest.dontMock('element-size'); on the unit tests fixes this error, but uncovers a new error:

TypeError: Cannot call method 'getDOMNode' of undefined in getChildHeight line 132

The same commit is the culprit, see here: https://github.com/BI/react-lazy-render/tree/unit-test-fix

@AlwaysMoreHats
Copy link
Author

Last one (I hope): TypeError: Cannot call method 'getDOMNode' of undefined

This is being caused because:

  1. componentDidMount calls getChildHeight to initially set the child height
  2. getChildHeight calls getElementHeight to get the measured height
  3. getElementHeight calls into element-size module to get the measured height
  4. element-size module calls element.getBoundingClientRect
  5. Elements in the testing environment return 0 for all values in the bounding rect
  6. height: 0 gets passed back up, which causes the next pass (i.e. the update, which happens immediately after the mount), to attempt to render 0 elements
  7. because there are no elements, no children render, thus no refs can be found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant