Skip to content

davidleston/await-invocation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published