-
Notifications
You must be signed in to change notification settings - Fork 90
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
How do you disable animations in tests? #119
Comments
We don't really support completely turning off animations, because that would let you miss a lot of potential failures. It would mean you were testing under unrealistic conditions. Instead, we give you control over the flow of time as seen by ember-animated, so you can make your animations go as fast or slow as you want to support the test you want to write. import {
setupAnimationTest,
time,
animationsSettled
} from 'ember-animated/test-support';
module('Acceptance | something', function(hooks) {
setupApplicationTest(hooks);
setupAnimationTest(hooks);
test('a thing', async function(assert) {
// run animations 100x faster than normal. If you want this for the whole
// test suite, you can say the same thing in `beforeEach`
time.runAtSpeed(100);
...
// let them finish. They will finish very fast, but not zero time.
await animationsSettled();
});
test('another thing', async function(assert) {
// take over the clock entirely
time.pause();
await click('...');
time.advance(10); // let the first 10 milliseconds of the animation run
assert(...); // inspect the state of things at that point in the animation
// let the rest of the animation finish quickly
time.runAtSpeed(100);
await animationsSettled();
assert(...); // see what the final state of things looks like
});
}); |
@ef4, thanks for your response! We weren't aware of |
Yeah, we need to document the test helpers better. |
Thanks, everyone; I've confirmed that this works for us. |
We have a weird bug that in Electron |
Having a hard time finding any information about this in the docs. We'd like animations to be completely disabled during tests. How do we do that?
I did find this liquid-fire issure. It recommends that we check
config.environment
. If'test'
, set animation durations to 0.We've done that, but we still sometimes get random test failures in our code that uses animations. In the end, we resorted to using
waitUntil
.The text was updated successfully, but these errors were encountered: