glenjamin / skin-deep

Test assertion helpers for use with React's shallowRender test utils

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React 16: This tree has no mounted instance

philipp-spiess opened this issue · comments

I'm in the process of upgrading our application to use the latest React version and we're facing issues with skin-deep.

It seems that other people already had success with the upgrade (c.f. #91), but I receive the following stack trace:

This tree has no mounted instance

  at Object.getMountedInstance (node_modules/skin-deep/skin-deep.js:61:13)
  at Object.<anonymous> (__tests__/unit/components/page/PageComponent-test.js:483:14)
  at process._tickCallback (internal/process/next_tick.js:103:7)

From a first look, it seems like:

shallowRenderer._instance._instance

is undefined for me.

If I remove the second ._instance it seems to work (although some tests are failing which might be due to the fact that shallowRender will no longer call componentDidUpdate, c.f. https://facebook.github.io/react/blog/2017/09/26/react-v16.0.html).

Here are the two lines about shallow rendering in the React 16 blog post, I'm not sure if that helps:

  • Shallow renderer no longer calls componentDidUpdate because DOM refs are not available. This also makes it consistent with componentDidMount (which does not get called in previous versions either).
  • Shallow renderer does not implement unstable_batchedUpdates anymore.

I'm afraid I don't really have time to look into React 16 compatibility myself at the moment. Although, I will have time to review/merge/publish any PRs relating to this stuff.

If someone can produce a failing testcase for React 16 that would be really helpful as a starting point for anyone investigating this.

Fixed by #94 - released in v1.2.0