diff --git a/cli/tests/unit_node/vm_test.ts b/cli/tests/unit_node/vm_test.ts index c43495e1d38dd3..6f190ab0857c0f 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 45c67526ed4e09..c4fda46bc9c794 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) {