Skip to content

Commit e2d1b09

Browse files
committed
Extend test coverage
1 parent d1a0250 commit e2d1b09

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

library/agent/hooks/instrumentation/codeTransformation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ t.test("modify rest parameter args", async (t) => {
449449
{
450450
nodeType: "MethodDefinition",
451451
name: "testFunction",
452-
identifier: "testmodule.test.js.testFunction.MethodDefinition.v1.0.0",
452+
identifier: "testpkg.test.js.testFunction.MethodDefinition.v1.0.0",
453453
inspectArgs: false,
454454
modifyArgs: true,
455455
modifyReturnValue: false,

library/agent/hooks/instrumentation/loadHook.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Hooks } from "../Hooks";
55
import * as mod from "node:module";
66
import { registerNodeHooks } from ".";
77
import { Agent } from "../../Agent";
8+
import { onModuleLoad } from "./loadHook";
89

910
t.test(
1011
"it throws an error if Node.js version is not supported",
@@ -190,3 +191,10 @@ t.test(
190191
t.equal(typeof fastify, "function");
191192
}
192193
);
194+
195+
t.test("call with invalid args", async (t) => {
196+
// @ts-expect-error Invalid args
197+
t.same(onModuleLoad("test", undefined, "test"), "test");
198+
// @ts-expect-error Invalid args
199+
t.same(onModuleLoad("test", undefined, undefined), undefined);
200+
});

library/agent/hooks/instrumentation/processGetBuiltin.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ t.test(
1717
async (t) => {
1818
createTestAgent();
1919

20+
// Before patched
21+
t.same(getBuiltinModuleWithoutPatching("http"), require("http"));
22+
2023
patchProcessGetBuiltinModule();
2124

2225
const hooks = new Hooks();
@@ -53,5 +56,7 @@ t.test(
5356
// @ts-expect-error Ignore original types
5457
getBuiltinModuleWithoutPatching(undefined);
5558
});
59+
60+
t.same(getBuiltinModuleWithoutPatching("sqlite"), require("node:sqlite"));
5661
}
5762
);

0 commit comments

Comments
 (0)