joshwcomeau / react-flip-move

Effortless animation between DOM changes (eg. list reordering) using the FLIP technique.
http://joshwcomeau.github.io/react-flip-move/examples
MIT License
4.09k stars 258 forks source link

Tests refactoring checklist #162

Open Hypnosphi opened 7 years ago

Hypnosphi commented 7 years ago

Initially, I created a project, but then I realised that it's not commentable so maybe an umbrella issue with checklist would be more useful, so I duplicate it as such.

@joshwcomeau has mentioned that he would like to have some improvements. So I decided to make some kind of checklist for what has to be done. Feel free to add anything that you think would be nice to do.

Definitely needed:

Maybe needed:

joshwcomeau commented 7 years ago

Awesome!

Yeah, so I originally wrote this module when I was completely inexperienced with React tests. I still don't have a ton of experience with it, but I can certainly see how bad they are now.

The easiest and most crucial win is just separating each test, as you say, so that each test mounts its own DOM, performs the test, and then unmounts it.

The false-positives thing has been very tricky in my experience - Working locally, the timing is very accurate, but on CI the timing is far less predictable. An animation set to 500ms will usually be within a few ms locally, but can take 1000-1500ms on travis, for reasons that aren't super clear to me.

The "maybe needed" stuff all sounds good to me - the helpers really should be unit-tested, and I like Istanbul/Enzyme.

Hypnosphi commented 7 years ago

I've added one more point: "use sinon fake timers instead of setTimeout". To do that, we also need to use some stub for requestAnimationFrame like this one, or write one ourselves as react-motion did.

Upd: OK, it's not really achievable as we're using CSS transitions

Hypnosphi commented 7 years ago

The false-positives thing has been very tricky in my experience - Working locally, the timing is very accurate, but on CI the timing is far less predictable. An animation set to 500ms will usually be within a few ms locally, but can take 1000-1500ms on travis, for reasons that aren't super clear to me.

Maybe the problem is that we don't take two skipped frames into account?

joshwcomeau commented 7 years ago

Maybe the problem is that we don't take two skipped frames into account?

Yeah, maybe if CI only runs at 1-2fps, it could explain it.

tobilen commented 7 years ago