Fail Jest tests for unhandled Promise rejections
The following fails in Jest:
it('fails', () => {
return Promise.reject(new Error('oops'));
});
However the following doesn't:
it("doesn't fail", () => {
setTimeout(() => Promise.reject(new Error('oops'), 1000));
});
We should register a listener for the unhandledRejection event and fail the test suite in that case.