diff options
Diffstat (limited to 'tests/testdata/node/rejection_handled_web_process.ts')
-rw-r--r-- | tests/testdata/node/rejection_handled_web_process.ts | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/testdata/node/rejection_handled_web_process.ts b/tests/testdata/node/rejection_handled_web_process.ts new file mode 100644 index 000000000..e331f8998 --- /dev/null +++ b/tests/testdata/node/rejection_handled_web_process.ts @@ -0,0 +1,26 @@ +import chalk from "npm:chalk"; +import process from "node:process"; + +console.log(chalk.red("Hello world!")); + +globalThis.addEventListener("unhandledrejection", (e) => { + console.log('globalThis.addEventListener("unhandledrejection");'); + e.preventDefault(); +}); + +globalThis.addEventListener("rejectionhandled", (_) => { + console.log("Web rejectionhandled"); +}); + +process.on("rejectionHandled", (_) => { + console.log("Node rejectionHandled"); +}); + +const a = Promise.reject(1); +setTimeout(() => { + a.catch(() => console.log("Added catch handler to the promise")); +}, 100); + +setTimeout(() => { + console.log("Success"); +}, 500); |