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

Fallback to setTimeout if requestAnimationFrame is not present #84

Merged
merged 1 commit into from
Feb 3, 2016

Conversation

raytiley
Copy link
Contributor

This is mostly to allow tests to run in PhantomJS without requring a 'requestAnimationFrame' pollyfill. Closes #43.

});

test('works without requestAnimationFrame', function(assert) {
var originalRaf = window.requestAnimationFrame;
Copy link
Contributor

Choose a reason for hiding this comment

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

this setup/teardown should be in setup/teardown of the module, otherwise it is possible for a failure to prevent restoration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had that but I can't get the teardown to wait for the component to be torn down, so the restoration happens causing the test to fail. Async is hard.

Trying to figure it out now.

@raytiley
Copy link
Contributor Author

Needed to call this.render again to clear the rendered component and force the teardown. With that in place replacing / restoring requestAnimationFrame in the setup / teardown methods works.

@rwjblue
Copy link
Member

rwjblue commented Jan 30, 2016

After chatting with @raytiley about the issue of forcing the test module's component to be destroyed, we discovered that it is not currently possible to actually run assertions after the component is destroyed!

I am working up a PR to ember-test-helpers to fix that oversight...

@rwjblue
Copy link
Member

rwjblue commented Jan 31, 2016

For now, wrapping in an {{#if someProp}}{{/if}} and toggle that to trigger destruction will be a decent work around until emberjs/ember-test-helpers#147 lands and is released.

Thanks to @mmun for that suggestion.

This is mostly to allow tests to run in PhantomJS without requring a 'requestAnimationFrame' pollyfill. Closes adopted-ember-addons#43.

The weirdness in the test is because there is no way currently to make sure the component is cleared and destroyed before the module's teardown hook is called. Wrapping the component in an if is a workaround until this: https://github.com/switchfly/ember-test-helpers/pull/147/files lands.
@raytiley
Copy link
Contributor Author

thanks @rwjblue and @mmun I've used your work around for now.

@rwjblue
Copy link
Member

rwjblue commented Feb 1, 2016

This seems good to me. I'm definitely in the camp of folks that would be happy if this worked out of the box:

ember new foo
cd foo
ember install ember-collection
ember test

@rwjblue
Copy link
Member

rwjblue commented Feb 1, 2016

@lukemelia / @krisselden / @stefanpenner - Any objections to this?

rwjblue added a commit that referenced this pull request Feb 3, 2016
Fallback to setTimeout if requestAnimationFrame is not present
@rwjblue rwjblue merged commit 194951d into adopted-ember-addons:master Feb 3, 2016
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

Successfully merging this pull request may close these issues.

3 participants