jest-shim.ts 421 B

1234567891011121314151617
  1. declare var global: NodeJS.Global;
  2. (global as any).requestAnimationFrame = (callback: any) => {
  3. setTimeout(callback, 0);
  4. };
  5. (Promise.prototype as any).finally = function(onFinally: any) {
  6. return this.then(
  7. /* onFulfilled */
  8. (res: any) => Promise.resolve(onFinally()).then(() => res),
  9. /* onRejected */
  10. (err: any) =>
  11. Promise.resolve(onFinally()).then(() => {
  12. throw err;
  13. })
  14. );
  15. };