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 instance null when involve async destruction #6095

Merged
merged 1 commit into from
Mar 9, 2016

Conversation

yiminghe
Copy link
Contributor

see tests in Files changed

componentWillUnmount: function() {
var self = this;
// some async animation
setImmediate(function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

setImmediate shouldn't be used, since it means we will never be able to run these tests in a real browser. https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate

Consider setTimeout instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setTimeout is mocked by jest, don't know how to simulate asynchronous in jest

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a problem with this? You guys should upgrade to jasmine2 so you can use the done feature of jasmine2 for async testing. Otherwise waitsFor is fine, just ugly API. You can also do jest.runAllTimers() to advance them manually – that way you can get rid of the waitsFor.

@zpao

Copy link
Contributor Author

Choose a reason for hiding this comment

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

runAllTimers run function provided to setTimeout synchronously. This test case needs asynchronization

Copy link
Contributor

Choose a reason for hiding this comment

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

what kind of async? You can also do jest.runAllImmediates.

@jimfb
Copy link
Contributor

jimfb commented Feb 24, 2016

This looks fine to me ( 👍 ) , just one minor change requested.

@yiminghe
Copy link
Contributor Author

After checking jest, use jest.runAllTimers(); is fine. thanks @cpojer

@facebook-github-bot
Copy link

@yiminghe updated the pull request.

@yiminghe
Copy link
Contributor Author

yiminghe commented Mar 9, 2016

ping @jimfb

@jimfb
Copy link
Contributor

jimfb commented Mar 9, 2016

@yiminghe Thanks for the ping! And thanks for the PR, this looks great! Might even be able to squeeze it into v15!

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