Open poteto opened 8 years ago
Option 2 is currently the most robust method. Velocity.mock
also works, but it assumes nobody has used any non-velocity-backed custom animations.
I would like to establish a unified API for timing control. Right now it's entirely up to each animation if it accepts a duration argument and how to interpret it. This has some surprising effects, like the fact that fade
can run twice as long as you think it will (because it spends a whole duration
fading out and another fading in).
This would create a natural place to provide global speed adjustment factors to run everything instantly under tests, or run everything slowly when trying to debug an animation.
Thanks for the clue. Here's slightly improved version, to set it as default (not sure if it works for transitions, I use only modals this far):
import config from './config/environment';
function getDuration() {
return config.environment === 'test' ? 0 : 250;
}
export default function() {
this.setDefault({duration: getDuration()});
}
Sorry to wake up an old issue but $.Velocity
is not set anymore. We have to do :
import Velocity from "velocity";
Velocity.mock = true;
I had to upgrade to the latest version because of an update to ember 2.10. It can be helpful for googlers (like me).
On behalf of Googlers everywhere, I salute you good sir.
How could we get this working for selenium tests as well?
We have a QA group that runs selenium tests against our app- it would be nice for them to disable animations to make them run more quickly.
For selenium, you can use techniques like the ones above, but instead of checking for config.environment === 'test'
, you could check for a special parameter in the URL, or a special cookie. Then configure selenium to use that parameter or cookie.
In my investigation, none of these correctly disable component animations. I tried using Velocity.mock, to disable a liquid-spacer
. It partially works, except some of liquid-fire's added styles still remain. I'm trying to take snapshots for Percy and this is somewhat annoying.
Ah, I take this back, Velocity.mock
basically did what I want but there are issues with the scaled testing container.
The issue is liquid-measured's use of getBoudingClientRect
, which gets the transformed size in pixels, not the original size. Should this be considered a bug? I'm inclined to think it is.
See #588 for my fix.
Currently, there is no option to disable liquid-fire transitions in a test environment, which slows down acceptance tests with unnecessary animations. It seems like the easiest way to do so is to set the duration of transitions to 0 at runtime, but it is not currently documented very well.
Possible ways to disable:
$.Velocity.mock = true
(thanks to @mmun for this tip)Import the app's
config/environment
intotransitions.js
(thanks @rwjblue):@ef4 – what is the preferred way to disable transitions in tests? I'm happy to submit a PR to update the docs when we've decided on the best approach.
Thank you!