summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/process_test.ts
diff options
context:
space:
mode:
authorDaniel Mizerski <duelsik@gmail.com>2023-12-01 07:36:11 +0100
committerGitHub <noreply@github.com>2023-12-01 15:36:11 +0900
commit687ae870d1e4e856b7ceee0a5511138459c68cb1 (patch)
tree19ce6f135a8d2edde9892dc43dd0608f744e9466 /cli/tests/unit_node/process_test.ts
parentfe90ba650d926fb006948499a96c9dabb149eed9 (diff)
fix(ext/node): add stubbed process.report (#21373)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'cli/tests/unit_node/process_test.ts')
-rw-r--r--cli/tests/unit_node/process_test.ts102
1 files changed, 102 insertions, 0 deletions
diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts
index ffb95413a..e79ff3468 100644
--- a/cli/tests/unit_node/process_test.ts
+++ b/cli/tests/unit_node/process_test.ts
@@ -825,3 +825,105 @@ Deno.test({
assertEquals(uv.errname(-1), "EPERM");
},
});
+
+Deno.test({
+ name: "process.report",
+ fn() {
+ // The process.report is marked as possibly undefined in node 18 typings
+ if (!process.report) throw "No process report";
+
+ assert(typeof process.report.directory === "string");
+ assert(typeof process.report.filename === "string");
+ assert(typeof process.report.getReport === "function");
+ assert(typeof process.report.reportOnFatalError === "boolean");
+ assert(typeof process.report.reportOnSignal === "boolean");
+ assert(typeof process.report.reportOnUncaughtException === "boolean");
+ assert(typeof process.report.signal === "string");
+ assert(typeof process.report.writeReport === "function");
+ },
+});
+
+Deno.test({
+ name: "process.report.writeReport unimplemented result",
+ fn() {
+ // The process.report is marked as possibly undefined in node 18 typings
+ if (!process.report) throw "No process report";
+
+ assertEquals(process.report.writeReport(), "");
+ },
+});
+
+Deno.test({
+ name: "process.report.getReport result",
+ fn() {
+ // The process.report is marked as possibly undefined in node 18 typings
+ if (!process.report) throw "No process report";
+
+ // deno-lint-ignore no-explicit-any
+ const result = process.report.getReport() as any;
+
+ // test and remove dynamic parts
+ assert(typeof result.header.filename === "string");
+ delete result.header.filename;
+ assert(typeof result.header.dumpEventTime === "object");
+ delete result.header.dumpEventTime;
+ assert(typeof result.header.dumpEventTimeStamp === "number");
+ delete result.header.dumpEventTimeStamp;
+ assert(typeof result.header.processId === "number");
+ delete result.header.processId;
+ assert(typeof result.header.cwd === "string");
+ delete result.header.cwd;
+ assert(typeof result.header.nodejsVersion === "string");
+ assert(result.header.nodejsVersion.startsWith("v"));
+ delete result.header.nodejsVersion;
+ assert(typeof result.header.arch === "string");
+ delete result.header.arch;
+ assert(typeof result.header.platform === "string");
+ delete result.header.platform;
+ assert(typeof result.header.componentVersions === "object");
+ delete result.header.componentVersions;
+ assert(typeof result.header.osName === "string");
+ delete result.header.osName;
+ assert(typeof result.header.osMachine === "string");
+ delete result.header.osMachine;
+ assert(Array.isArray(result.header.cpus));
+ delete result.header.cpus;
+ assert(typeof result.header.networkInterfaces === "object");
+ delete result.header.networkInterfaces;
+ assert(typeof result.header.host === "string");
+ delete result.header.host;
+
+ // test hardcoded part
+ assertEquals(result, {
+ header: {
+ reportVersion: 3,
+ event: "JavaScript API",
+ trigger: "GetReport",
+ threadId: 0,
+ commandLine: ["node"],
+ glibcVersionRuntime: "2.38",
+ glibcVersionCompiler: "2.38",
+ wordSize: 64,
+ release: {
+ name: "node",
+ headersUrl:
+ "https://nodejs.org/download/release/v21.2.0/node-v21.2.0-headers.tar.gz",
+ sourceUrl:
+ "https://nodejs.org/download/release/v21.2.0/node-v21.2.0.tar.gz",
+ },
+ osRelease: undefined,
+ osVersion: undefined,
+ },
+ javascriptStack: undefined,
+ javascriptHeap: undefined,
+ nativeStack: undefined,
+ resourceUsage: undefined,
+ uvthreadResourceUsage: undefined,
+ libuv: undefined,
+ workers: [],
+ environmentVariables: undefined,
+ userLimits: undefined,
+ sharedObjects: undefined,
+ });
+ },
+});