Restrict Cypress uncaught exception suppression to known benign errors

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
2026-03-08 13:49:51 +08:00
parent fc43ca67ca
commit d5464ebc2d
3 changed files with 62 additions and 3 deletions

View File

@@ -0,0 +1,31 @@
import { describe, expect, it } from "vitest";
import {
getCypressUncaughtExceptionDecision,
shouldIgnoreUncaughtException,
} from "../../../cypress/support/uncaughtExceptionPolicy";
describe("shouldIgnoreUncaughtException", () => {
it("returns true for known benign ResizeObserver errors", () => {
expect(
shouldIgnoreUncaughtException(new Error("ResizeObserver loop limit exceeded")),
).toBe(true);
});
it("returns false for unknown runtime errors", () => {
expect(shouldIgnoreUncaughtException(new Error("TypeError: x is undefined"))).toBe(false);
});
it("returns false for Cypress handler when the error should be ignored", () => {
expect(
getCypressUncaughtExceptionDecision(
new Error("ResizeObserver loop completed with undelivered notifications."),
),
).toBe(false);
});
it("returns undefined for Cypress handler when the error should fail the test", () => {
expect(
getCypressUncaughtExceptionDecision(new Error("TypeError: x is undefined")),
).toBeUndefined();
});
});