Skip to content

Conversation

@raunofreiberg
Copy link
Contributor

@raunofreiberg raunofreiberg commented Mar 21, 2018

Follow up PR for #12407. Adds a regression test related to issue #12299.

Before the #12407 fix this test case would fail as:

Expected the function not to throw an error matching:
  [TypeError: Cannot read property '_warnedAboutRefsInRender' of null]
Instead, it threw:
  TypeError: Cannot read property '_warnedAboutRefsInRender' of null

@raunofreiberg
Copy link
Contributor Author

Maybe something like this @gaearon?

expect(() => {
ReactDOM.render(<App />, container);
}).not.toThrow(stateNodeErr);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's enough to replace this whole block with just ReactDOM.render(<App />, container). If it did throw, the test would fail anyway. You can remove the error declaration too.

}
});

it('should not throw a TypeError when reading stateNode on ReactCurrentOwner', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We avoid implementation details in test titles. Just "should not crash calling findDOMNode inside a functional component".

@raunofreiberg
Copy link
Contributor Author

Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants