uptime-kuma/test/backend-test/notification-providers/test-notification-provider.js
Anurag Ekkati 0c9354d5f4
fix: Expand the logging around AggregateError (#6664)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-11 00:59:04 +00:00

34 lines
1.2 KiB
JavaScript

const { describe, test } = require("node:test");
const assert = require("node:assert");
const NotificationProvider = require("../../../server/notification-providers/notification-provider");
describe("NotificationProvider.throwGeneralAxiosError()", () => {
const provider = new NotificationProvider();
test("expands AggregateError causes", () => {
let err1 = new Error("connect ECONNREFUSED 127.0.0.1:443");
err1.code = "ECONNREFUSED";
let err2 = new Error("connect ECONNREFUSED ::1:443");
err2.code = "ECONNREFUSED";
let aggErr = new AggregateError([err1, err2], "AggregateError");
assert.throws(() => provider.throwGeneralAxiosError(aggErr), {
message: /^AggregateError - caused by: .+/,
});
});
test("expands AggregateError wrapped in error.cause", () => {
let innerErr = new Error("connect ETIMEDOUT 10.0.0.1:443");
innerErr.code = "ETIMEDOUT";
let aggErr = new AggregateError([innerErr], "AggregateError");
let outerErr = new Error("Request failed");
outerErr.cause = aggErr;
assert.throws(() => provider.throwGeneralAxiosError(outerErr), {
message: /^Request failed - caused by: .+/,
});
});
});