sharkcore / tweenz

Tweens for Express
7 stars 1 forks source link

Provide a way to flush the promise queue for async tweenz #31

Open magicmark opened 3 years ago

magicmark commented 3 years ago

Note that we don't call await on each tween:

https://github.com/sharkcore/tweenz/blob/7a733f2597aa167aa1227d287def755b590160a0/src/index.js#L59-L62

This is deliberate - so that code can execute "after" a request (the whole point of tweenz). Putting await here would create an infinite promise loop.

This behaviour is mostly ok, except when you want to run tests on tweenz. Code can run after the test completes :)

This can be worked around by using something like https://www.npmjs.com/package/flush-promises a bunch of times before writing any assertions.

The 'proper' fix may be some global function that can be used in tests to properly await the results of tweens