Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
magicmark opened this issue Apr 2, 2021 · 0 comments
Open

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

magicmark opened this issue Apr 2, 2021 · 0 comments

Comments

@magicmark
Copy link
Contributor

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

tweenz/src/index.js

Lines 59 to 62 in 7a733f2

// Call each tween
tweens.forEach(tween => {
tween(requestDetails, req, res);
});

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant