-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrendererGlobalErrors.test.ts
More file actions
63 lines (54 loc) · 2.29 KB
/
rendererGlobalErrors.test.ts
File metadata and controls
63 lines (54 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { describe, expect, it } from "vitest";
import {
isIgnorableRejection,
isIgnorableWindowError,
isResizeObserverLoopError,
isViewTransitionInvalidStateError,
isViewTransitionSkippedError,
} from "./rendererGlobalErrors";
describe("rendererGlobalErrors", () => {
it("recognizes browser ResizeObserver loop diagnostics", () => {
expect(
isResizeObserverLoopError(
new Error("ResizeObserver loop completed with undelivered notifications."),
),
).toBe(true);
expect(isResizeObserverLoopError("ResizeObserver loop limit exceeded")).toBe(true);
});
it("does not ignore normal errors", () => {
expect(isResizeObserverLoopError(new Error("render failed"))).toBe(false);
});
it("ignores ResizeObserver loop window error events", () => {
const event = new ErrorEvent("error", {
message: "ResizeObserver loop completed with undelivered notifications.",
});
expect(isIgnorableWindowError(event)).toBe(true);
});
it("recognizes view-transition skipped AbortError rejections", () => {
const abort = new DOMException("Transition was skipped", "AbortError");
expect(isViewTransitionSkippedError(abort)).toBe(true);
expect(isIgnorableRejection(abort)).toBe(true);
});
it("does not ignore unrelated AbortErrors", () => {
const abort = new DOMException("Fetch aborted", "AbortError");
expect(isViewTransitionSkippedError(abort)).toBe(false);
expect(isIgnorableRejection(abort)).toBe(false);
});
it("does not ignore non-AbortError rejections with similar messages", () => {
expect(isIgnorableRejection(new Error("Transition was skipped"))).toBe(false);
expect(isIgnorableRejection("Transition was skipped")).toBe(false);
});
it("recognizes view-transition invalid-state InvalidStateError rejections", () => {
const err = new DOMException(
"Transition was aborted because of invalid state",
"InvalidStateError",
);
expect(isViewTransitionInvalidStateError(err)).toBe(true);
expect(isIgnorableRejection(err)).toBe(true);
});
it("does not ignore unrelated InvalidStateErrors", () => {
const err = new DOMException("IndexedDB transaction inactive", "InvalidStateError");
expect(isViewTransitionInvalidStateError(err)).toBe(false);
expect(isIgnorableRejection(err)).toBe(false);
});
});