Testing recommendations #1326
Replies: 6 comments 3 replies
-
For the import { Globals } from 'react-spring'
Globals.assign({
requestAnimationFrame: fn => setTimeout(fn, 16),
}) In the few tests we have for the We have a fork of Beyond that, I don't have much advice currently. We should definitely come up with some strategies for automation of visual tests. When it comes to animation, unit tests can only guarantee so much I think. |
Beta Was this translation helpful? Give feedback.
-
Nice, thanks so much, this is a life saver for us. Our app runs in iframe, and firefox throttles |
Beta Was this translation helpful? Give feedback.
-
I want to turn animations off when doing visual regression testing snapshots. Right now I feel like my best option is to completely stub the entire library with some pretty flimsy/brittle mocked out hooks. It'd be great if there was an official way to achieve this or even an official mocked alternative. I kinda hoped it was as simple as setting some global config property or something, but I've not found anything in the docs... |
Beta Was this translation helpful? Give feedback.
-
@jackmellis See here: #668 (comment) |
Beta Was this translation helpful? Give feedback.
-
@aleclarson that comment seems like its for v9 only which is not yet released, how do we do that in v8 ? |
Beta Was this translation helpful? Give feedback.
-
That discussion was really useful to solve my issues, but really, this should be in the Testing section of the docs... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Thanks for great library!
I had some hard time testing some of my animated components.
I have kind of figured it out at the end, but it was pretty pain to setup, mainly because there are no docs out there at all. (maybe somebody would have a better approach)
Here is the approach I used to test my component:
Test for this component:
This is using jest (24.8.0, with JSDOM 15) and react-testing-library.
I had to also mock requestAnimationFrame.
You can do it like this:
global.requestAnimationFrame = fn => setTimeout(fn, 16);
.It needs to go to
setup-jest
as if its inside test file, it doesn't work.Beta Was this translation helpful? Give feedback.
All reactions