Skip to content

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

@magicmark

Description

@magicmark

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions