diff options
-rw-r--r-- | tests/integration/node_unit_tests.rs | 9 | ||||
-rw-r--r-- | tests/specs/node/rejection_handled_web_process/__test__.jsonc | 6 | ||||
-rw-r--r-- | tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts (renamed from tests/testdata/node/rejection_handled_web_process.ts) | 13 | ||||
-rw-r--r-- | tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out (renamed from tests/testdata/node/rejection_handled_web_process.ts.out) | 0 | ||||
-rwxr-xr-x | tools/lint.js | 2 |
5 files changed, 18 insertions, 12 deletions
diff --git a/tests/integration/node_unit_tests.rs b/tests/integration/node_unit_tests.rs index a034897ef..b067f3121 100644 --- a/tests/integration/node_unit_tests.rs +++ b/tests/integration/node_unit_tests.rs @@ -202,12 +202,3 @@ itest!(unhandled_rejection_web_process { envs: env_vars_for_npm_tests(), http_server: true, }); - -// Ensure that Web `onrejectionhandled` is fired before -// Node's `process.on('rejectionHandled')`. -itest!(rejection_handled_web_process { - args: "run -A --quiet node/rejection_handled_web_process.ts", - output: "node/rejection_handled_web_process.ts.out", - envs: env_vars_for_npm_tests(), - http_server: true, -}); diff --git a/tests/specs/node/rejection_handled_web_process/__test__.jsonc b/tests/specs/node/rejection_handled_web_process/__test__.jsonc new file mode 100644 index 000000000..8f60df4f5 --- /dev/null +++ b/tests/specs/node/rejection_handled_web_process/__test__.jsonc @@ -0,0 +1,6 @@ +// Ensure that Web `onrejectionhandled` is fired before +// Node's `process.on('rejectionHandled')`. +{ + "args": "run -A --quiet rejection_handled_web_process.ts", + "output": "rejection_handled_web_process.ts.out" +} diff --git a/tests/testdata/node/rejection_handled_web_process.ts b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts index a5136ca3d..c7957082f 100644 --- a/tests/testdata/node/rejection_handled_web_process.ts +++ b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts @@ -3,6 +3,8 @@ import process from "node:process"; console.log(chalk.red("Hello world!")); +const { promise, resolve } = Promise.withResolvers(); + globalThis.addEventListener("unhandledrejection", (e) => { console.log('globalThis.addEventListener("unhandledrejection");'); e.preventDefault(); @@ -14,6 +16,7 @@ globalThis.addEventListener("rejectionhandled", (_) => { process.on("rejectionHandled", (_) => { console.log("Node rejectionHandled"); + resolve(); }); const a = Promise.reject(1); @@ -21,6 +24,12 @@ setTimeout(() => { a.catch(() => console.log("Added catch handler to the promise")); }, 100); -setTimeout(() => { +const exitTimeout = setTimeout(() => { + console.error("timeout expired"); + Deno.exit(1); +}, 30_000); + +promise.then(() => { console.log("Success"); -}, 1000); + clearTimeout(exitTimeout); +}); diff --git a/tests/testdata/node/rejection_handled_web_process.ts.out b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out index e6fefede2..e6fefede2 100644 --- a/tests/testdata/node/rejection_handled_web_process.ts.out +++ b/tests/specs/node/rejection_handled_web_process/rejection_handled_web_process.ts.out diff --git a/tools/lint.js b/tools/lint.js index aa3b417cc..d4fb4e9a0 100755 --- a/tools/lint.js +++ b/tools/lint.js @@ -216,7 +216,7 @@ async function ensureNoNewITests() { // Read the comment above. Please don't increase these numbers! "lsp_tests.rs": 0, "node_compat_tests.rs": 4, - "node_unit_tests.rs": 3, + "node_unit_tests.rs": 2, "npm_tests.rs": 98, "pm_tests.rs": 0, "publish_tests.rs": 0, |