1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/tests/testdata/node/rejection_handled_web_process.ts
Bartek Iwańczuk 7b02f2aba6
test: deflake tests for rejection handled (#23448)
Fixes flakiness for rejection handled tests on Windows (7 failures in
the past day).
2024-04-18 23:40:15 +00:00

26 lines
631 B
TypeScript

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");
}, 1000);