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

Improve async-related React tests #16968

Closed
chrisronline opened this issue Mar 5, 2018 · 2 comments
Closed

Improve async-related React tests #16968

chrisronline opened this issue Mar 5, 2018 · 2 comments
Labels
Team:Visualizations Visualization editors, elastic-charts and infrastructure test

Comments

@chrisronline
Copy link
Contributor

We had this weird code supporting our React tests that contained async mounting logic (see here).

However, after digging into #16895 with @cjcenizal, the comments or issue didn't help me understand what was happening so I dug in more and found a simpler solution that I think will make this easier to maintain and understand moving forward.

We can replace the three await component.update() calls with:

// Ensure all promises resolve
await new Promise(resolve => process.nextTick(resolve));
// Ensure the state changes are reflected
component.update();

I think this makes more sense and should be more helpful for people looking at this in the future.

cc @jen-huang @bmcconaghy

@cjcenizal
Copy link
Contributor

Nice! It might be worth extracting part or all of this into a helper function in the test module.

@timroes timroes added test Team:Visualizations Visualization editors, elastic-charts and infrastructure and removed :Management DO NOT USE labels Nov 27, 2018
@timroes
Copy link
Contributor

timroes commented Nov 27, 2018

I will close this as too specific right now, and there are no short-term plans to implement this.

@timroes timroes closed this as completed Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Visualizations Visualization editors, elastic-charts and infrastructure test
Projects
None yet
Development

No branches or pull requests

3 participants