await-invocation
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

await-invocation

Provides the ability to await until a function has been invoked. Created to help test asynchronous functions without having to wait for them to finish, namely Temporal.io workflows.

Example usage

Imagine you have an asynchronous function named systemUnderTest. You wish to test systemUnderTest without waiting for the returned promise to resolve. This example waits for two calls to a mock function:

const mock = jest.fn();
const {proxy, nextCall} = awaitInvocation(mock);
systemUnderTest(proxy); // note: no await
await nextCall();
await nextCall();
expect(mock).toHaveBeenCalledTimes(2);

Author

👤 David Leston

Show your support

Give a ⭐️ if this project helped you!

Package Sidebar

Install

npm i await-invocation

Weekly Downloads

1

Version

1.0.1

License

(MIT OR Apache-2.0)

Unpacked Size

8.58 kB

Total Files

7

Last publish

Collaborators

  • davidleston