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

tests: add regression test for reading ReactCurrentOwner stateNode #12412

Merged
merged 2 commits into from
Apr 16, 2018
Merged

tests: add regression test for reading ReactCurrentOwner stateNode #12412

merged 2 commits into from
Apr 16, 2018

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.

@@ -377,6 +377,26 @@ describe('ReactDOM', () => {
}
});

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