diff options
Diffstat (limited to 'cli/tests/testdata/node')
| -rw-r--r-- | cli/tests/testdata/node/rejection_handled_web_process.ts | 26 | ||||
| -rw-r--r-- | cli/tests/testdata/node/rejection_handled_web_process.ts.out | 7 |
2 files changed, 33 insertions, 0 deletions
diff --git a/cli/tests/testdata/node/rejection_handled_web_process.ts b/cli/tests/testdata/node/rejection_handled_web_process.ts new file mode 100644 index 000000000..00d943feb --- /dev/null +++ b/cli/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")); +}, 10); + +setTimeout(() => { + console.log("Success"); +}, 50); diff --git a/cli/tests/testdata/node/rejection_handled_web_process.ts.out b/cli/tests/testdata/node/rejection_handled_web_process.ts.out new file mode 100644 index 000000000..3a4e2ac23 --- /dev/null +++ b/cli/tests/testdata/node/rejection_handled_web_process.ts.out @@ -0,0 +1,7 @@ +[WILDCARD] +Hello world! +globalThis.addEventListener("unhandledrejection"); +Added catch handler to the promise +Web rejectionhandled +Node rejectionHandled +Success |
