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

Fix test that checks for double-rendering of ConnectedRouter component #219

Open
jakewies opened this issue Dec 27, 2018 · 0 comments
Open

Comments

@jakewies
Copy link

jakewies commented Dec 27, 2018

Note: This issue has nothing to do with any user-facing code. Priority should be given to other issues affecting users.


In a recent PR @AnnaTsu fixed a crucial issue regarding ConnectedRouter rendering on unrelated Redux store updates.

The work done in that PR did not address an ongoing double-render issue, however a future PR did. Both fixes are now merged into the master branch as of v6.1.0, and ConnectedRouter is now behaving as expected.

There is still an issue though. In PR 208, @AnnaTsu introduced a test to confirm that ConnectedRouter only renders once on initialization:

it('only renders one time when mounted', () => {
  // ...     
})

This test was passing, but it should've failed. Why? ConnectedRouter was still rendering twice on init. That issue was not addressed until PR 218.

This test is creating a false positive.

Goal

We should aim to figure out why this test was not working as expected in PR 208, and fix it so that it does confirm ConnectedRouter only renders once on init.

In order to find the root cause of this problem, it's probably best to have the call to handleLocationChange inside of componentDidMount pass isFirstRendering = false to create a failing test:

// ConnectedRouter.js

// ...
handleLocationChange(history.location, history.action, false)

This is just to "undo" the work done in PR 218, for testing purposes to confirm that the test fails. Once the test is red, revert the code and confirm the test passes.

These are just my initial thoughts on how to confirm a working test in the master.

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