diff options
Diffstat (limited to 'cli/tests/testdata/run')
| -rw-r--r-- | cli/tests/testdata/run/rejection_handled.out | 5 | ||||
| -rw-r--r-- | cli/tests/testdata/run/rejection_handled.ts | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/cli/tests/testdata/run/rejection_handled.out b/cli/tests/testdata/run/rejection_handled.out new file mode 100644 index 000000000..5c06fcd2b --- /dev/null +++ b/cli/tests/testdata/run/rejection_handled.out @@ -0,0 +1,5 @@ +[WILDCARD] +unhandledrejection 1 Promise { <rejected> 1 } +Added catch handler to the promise +rejectionhandled 1 Promise { <rejected> 1 } +Success diff --git a/cli/tests/testdata/run/rejection_handled.ts b/cli/tests/testdata/run/rejection_handled.ts new file mode 100644 index 000000000..f058ff966 --- /dev/null +++ b/cli/tests/testdata/run/rejection_handled.ts @@ -0,0 +1,17 @@ +window.addEventListener("unhandledrejection", (event) => { + console.log("unhandledrejection", event.reason, event.promise); + event.preventDefault(); +}); + +window.addEventListener("rejectionhandled", (event) => { + console.log("rejectionhandled", event.reason, event.promise); +}); + +const a = Promise.reject(1); +setTimeout(async () => { + a.catch(() => console.log("Added catch handler to the promise")); +}, 10); + +setTimeout(() => { + console.log("Success"); +}, 50); |
