From 73ab0efac8f4bd61adce30bef50dc1ebaa29928e Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 23 May 2024 10:33:20 +0530 Subject: [PATCH] fix(ext/noe): add stubs for perf_hooks.PerformaceObserver Fixes https://github.com/denoland/deno/issues/23943 --- ext/node/polyfills/perf_hooks.ts | 11 +++++++++-- 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 44ab88f98818f8..b58321ffad91ce 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 d6f58d1cf87aa8..86c4aee4c97e32 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(perfHooks.PerformanceEntry, PerformanceEntry); + assertEquals(perfHooks.PerformanceObserver, PerformanceObserver); }, });