diff --git a/cli/tests/unit_node/vm_test.ts b/cli/tests/unit_node/vm_test.ts index c43495e1d3..6f190ab085 100644 --- a/cli/tests/unit_node/vm_test.ts +++ b/cli/tests/unit_node/vm_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { runInNewContext } from "node:vm"; +import { isContext, runInNewContext } from "node:vm"; import { assertEquals, assertThrows, @@ -55,3 +55,15 @@ Deno.test({ } }, }); + +Deno.test({ + name: "vm isContext", + fn() { + // Currently we do not expose VM contexts so this is always false. + const obj = {}; + assertEquals(isContext(obj), false); + assertEquals(isContext(globalThis), false); + const sandbox = runInNewContext("{}"); + assertEquals(isContext(sandbox), false); + }, +}); diff --git a/ext/node/polyfills/vm.ts b/ext/node/polyfills/vm.ts index 45c67526ed..c4fda46bc9 100644 --- a/ext/node/polyfills/vm.ts +++ b/ext/node/polyfills/vm.ts @@ -75,7 +75,8 @@ export function runInThisContext( } export function isContext(_maybeContext: any) { - notImplemented("isContext"); + // TODO(@littledivy): Currently we do not expose contexts so this is always false. + return false; } export function compileFunction(_code: string, _params: any, _options: any) {