From 75efc74931c1021fdc41c96f45a4e20ae4609e50 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Fri, 17 May 2024 16:24:07 +0200 Subject: fix(node): instantiating process class without new (#23865) Popular test runners like Jest instantiate a new `Process` object themselves and expect the class constructor to be callable without the `new` keyword. This PR refactors our `Process` class implementation from a proper ES2015 class to an ES5-style class which can be invoked both with and without the `new` keyword like in Node. Fixes https://github.com/denoland/deno/issues/23863 --- tests/unit_node/process_test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts index 6b90a30ba..491a70bfc 100644 --- a/tests/unit_node/process_test.ts +++ b/tests/unit_node/process_test.ts @@ -1094,3 +1094,12 @@ Deno.test({ assert(v >= 0); }, }); + +// Test for https://github.com/denoland/deno/issues/23863 +Deno.test({ + name: "instantiate process constructor without 'new' keyword", + fn() { + // This would throw + process.constructor.call({}); + }, +}); -- cgit v1.2.3