Skip to content

Improve error boundaries tests - #7569

Merged
sophiebits merged 1 commit into
react:masterfrom
millermedeiros:boundarytest
Aug 31, 2016
Merged

Improve error boundaries tests#7569
sophiebits merged 1 commit into
react:masterfrom
millermedeiros:boundarytest

Conversation

@millermedeiros

Copy link
Copy Markdown
Contributor

this is kinda of a follow up to #7558 where @spicyj said:

Can you make a custom componentDidMount instead of mocking putListener? This current test won't verify that the queue is reset if we were to refactor the events system and how putListener works. Also, no need for the parens within render.
#7558 (comment)

the new tests makes sure the methods are executed in the proper order and don't rely on EventPluginHub anymore - the 'does not register event handlers for unmounted children' test still uses EventPluginHub since it looks like it makes sense to leave that check there...

also removed some parentheses and wrapped some lines.

container.innerHTML = ReactDOMServer.renderToString(<Boundary />);
expect(container.firstChild.innerHTML).toBe('Happy Birthday!');
expect(EventPluginHub.putListener).not.toBeCalled();
// note: renderToString does not call componentDidMount

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure why this even uses renderToString. Mind changing it to use ReactDOM.render so that we test the queueing behavior better? (See, I didn't even notice that the old test was testing the wrong thing but now that componentDidMount is completely absent here it's much more obvious. Thanks.)

@aweary aweary Aug 27, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we have tests for both renderToString and ReactDOM.render? The title of this test block should be changed too if we're not testing SSR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In most cases it's fine to just test client rendering since the server codepath is mostly a subset of the client one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, updated the test to use ReactDOM.render instead. FYI, original test was introduced by #6694

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rawr. okay.

@sophiebits

Copy link
Copy Markdown
Contributor

lgtm otherwise, thanks!

@ghost ghost added the CLA Signed label Aug 27, 2016
@millermedeiros

Copy link
Copy Markdown
Contributor Author

this should be good to go, updated all the test to use ReactDOM.render instead of renderToString

@sophiebits

Copy link
Copy Markdown
Contributor

Thanks!

@ghost ghost added the CLA Signed label Aug 31, 2016
@millermedeiros
millermedeiros deleted the boundarytest branch August 31, 2016 05:35
@zpao zpao modified the milestones: 15.3.2, 15-next Sep 8, 2016
zpao pushed a commit that referenced this pull request Sep 15, 2016
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
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.

4 participants