-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Add createDeferredPromise
#164
Conversation
A new function has been added for creating a deferred Promise. Deferred Promises can be useful for tracking async task, e.g. to prevent async tasks from overlapping, or to queue up async tasks. We use this pattern in multiple places in core and the extension.
expect(() => resolve()).not.toThrow(); | ||
}); | ||
|
||
describe('when suppressUnhandledRejection is set', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried writing a test for when this was false, but there was no way to catch the unhandledRejection
event. Apparently in the environment Jest runs tests in, the event always bubbles up to the parent process. Attaching an event handler for that event has no effect here. And there was no easy way to attach an event handler to the parent process, I think it'd require patching Jest or creating a custom test environment.
This allows creating deferred Promises that return values
A new function has been added for creating a deferred Promise. Deferred Promises can be useful for tracking async task, e.g. to prevent async tasks from overlapping, or to queue up async tasks. We use this pattern in multiple places in core and the extension.