summaryrefslogtreecommitdiff
path: root/tests/unit_node/perf_hooks_test.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-11-19 16:49:25 +0530
committerGitHub <noreply@github.com>2024-11-19 16:49:25 +0530
commit069bc15030225393f7d05521505316066464bdbd (patch)
tree8665758ced09dc2876aeedadffe27d2f0e181a09 /tests/unit_node/perf_hooks_test.ts
parent0e2f6e38e7b93e42099f546ef2c01629964d095a (diff)
feat(ext/node): perf_hooks.monitorEventLoopDelay() (#26905)
Fixes https://github.com/denoland/deno/issues/20961 Depends on https://github.com/denoland/deno_core/pull/965 and https://github.com/denoland/deno_core/pull/966
Diffstat (limited to 'tests/unit_node/perf_hooks_test.ts')
-rw-r--r--tests/unit_node/perf_hooks_test.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/tests/unit_node/perf_hooks_test.ts b/tests/unit_node/perf_hooks_test.ts
index 8247f9fd3..83d006222 100644
--- a/tests/unit_node/perf_hooks_test.ts
+++ b/tests/unit_node/perf_hooks_test.ts
@@ -5,7 +5,7 @@ import {
performance,
PerformanceObserver,
} from "node:perf_hooks";
-import { assertEquals, assertThrows } from "@std/assert";
+import { assert, assertEquals, assertThrows } from "@std/assert";
Deno.test({
name: "[perf_hooks] performance",
@@ -73,11 +73,16 @@ Deno.test("[perf_hooks]: eventLoopUtilization", () => {
assertEquals(typeof obj.utilization, "number");
});
-Deno.test("[perf_hooks]: monitorEventLoopDelay", () => {
- const e = assertThrows(() => {
- monitorEventLoopDelay({ resolution: 1 });
- });
+Deno.test("[perf_hooks]: monitorEventLoopDelay", async () => {
+ const e = monitorEventLoopDelay();
+ assertEquals(e.count, 0);
+ e.enable();
- // deno-lint-ignore no-explicit-any
- assertEquals((e as any).code, "ERR_NOT_IMPLEMENTED");
+ await new Promise((resolve) => setTimeout(resolve, 100));
+
+ assert(e.min > 0);
+ assert(e.minBigInt > 0n);
+ assert(e.count > 0);
+
+ e.disable();
});