diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-05-23 04:59:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 04:59:20 -0700 |
commit | aeafb7b39ed6e0cb7601be53f63a5c6e0f2aa1a8 (patch) | |
tree | 9be8895ff802db01035f769522c3006f0bf9db96 | |
parent | fa1ba256d20236042455abb31a92d2a1d27ee58f (diff) |
fix(ext/node): add stubs for perf_hooks.PerformaceObserver (#23958)
Fixes https://github.com/denoland/deno/issues/23943
-rw-r--r-- | ext/node/polyfills/perf_hooks.ts | 11 | ||||
-rw-r--r-- | tests/unit_node/perf_hooks_test.ts | 5 |
2 files changed, 12 insertions, 4 deletions
diff --git a/ext/node/polyfills/perf_hooks.ts b/ext/node/polyfills/perf_hooks.ts index 44ab88f98..b58321ffa 100644 --- a/ext/node/polyfills/perf_hooks.ts +++ b/ext/node/polyfills/perf_hooks.ts @@ -9,8 +9,15 @@ import { PerformanceEntry, } from "ext:deno_web/15_performance.js"; -// FIXME(bartlomieju) -const PerformanceObserver = undefined; +class PerformanceObserver { + observe() { + notImplemented("PerformanceObserver.observe"); + } + disconnect() { + notImplemented("PerformanceObserver.disconnect"); + } +} + const constants = {}; const performance: diff --git a/tests/unit_node/perf_hooks_test.ts b/tests/unit_node/perf_hooks_test.ts index d6f58d1cf..86c4aee4c 100644 --- a/tests/unit_node/perf_hooks_test.ts +++ b/tests/unit_node/perf_hooks_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import * as perfHooks from "node:perf_hooks"; -import { performance } from "node:perf_hooks"; +import { performance, PerformanceObserver } from "node:perf_hooks"; import { assertEquals, assertThrows } from "@std/assert/mod.ts"; Deno.test({ @@ -44,9 +44,10 @@ Deno.test({ }); Deno.test({ - name: "[perf_hooks] PerformanceEntry", + name: "[perf_hooks] PerformanceEntry & PerformanceObserver", fn() { assertEquals<unknown>(perfHooks.PerformanceEntry, PerformanceEntry); + assertEquals<unknown>(perfHooks.PerformanceObserver, PerformanceObserver); }, }); |