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

Add syncify test helper #301

Merged
merged 3 commits into from
Jan 12, 2018

Conversation

chrisronline
Copy link
Contributor

@cjcenizal recommended adding this from this discussion

This helper allows you to properly test async functions that throw exceptions.

Here is working code using the helper:

const fn = await syncify(() => asyncFn());
expect(fn).toThrow();

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just one request.

@@ -0,0 +1,10 @@
// Helper designed to help test async/await functions that throw exceptions
// https://github.com/facebook/jest/issues/1377
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add your example code to this comment:

Example usage:
const fn = await syncify(() => asyncFn());
expect(fn).toThrow();

@cjcenizal
Copy link
Contributor

Oh and can you add a note to the CHANGELOG.md?

@chrisronline
Copy link
Contributor Author

Done!

@chrisronline chrisronline merged commit 4decff2 into elastic:master Jan 12, 2018
@chrisronline chrisronline deleted the add-syncify-test-helper branch January 12, 2018 19:27
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

Successfully merging this pull request may close these issues.

2 participants