Identify what will appear once animation ends and look for it. For example if after an animation text “Hello, I’m back” appears then run:
wait { text("Hello, I'm back") }
If the animation are so slow that it may hit the timeout defined, then use some while
while texts("Hello, I'm back).size == 0 do
sleep 0.5
end
In this last one its better to also have one counter incrementing and if it reaches a number you define just raise an exception to fail the test or it may run forever. Examples in ruby, just adapt to your favorite language.