Skip to content

Commit 9b79419

Browse files
committed
test(telemetry): add enabled SDK path tests for 4xx/5xx coverage
1 parent ef285ce commit 9b79419

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/lib/telemetry.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,43 @@ describe("withTelemetry", () => {
138138
})
139139
).rejects.toThrow(error);
140140
});
141+
142+
describe("with telemetry enabled", () => {
143+
beforeEach(() => {
144+
delete process.env[ENV_VAR];
145+
});
146+
147+
test("propagates 4xx ApiError through enabled SDK path", async () => {
148+
const error = new ApiError("Not found", 404, "Issue not found");
149+
await expect(
150+
withTelemetry(() => {
151+
throw error;
152+
})
153+
).rejects.toThrow(error);
154+
});
155+
156+
test("propagates 5xx ApiError through enabled SDK path", async () => {
157+
const error = new ApiError("Server error", 500, "Internal error");
158+
await expect(
159+
withTelemetry(() => {
160+
throw error;
161+
})
162+
).rejects.toThrow(error);
163+
});
164+
165+
test("propagates generic Error through enabled SDK path", async () => {
166+
await expect(
167+
withTelemetry(() => {
168+
throw new Error("unexpected bug");
169+
})
170+
).rejects.toThrow("unexpected bug");
171+
});
172+
173+
test("returns result through enabled SDK path", async () => {
174+
const result = await withTelemetry(() => 42);
175+
expect(result).toBe(42);
176+
});
177+
});
141178
});
142179

143180
describe("isClientApiError", () => {

0 commit comments

Comments
 (0)