Skip to content

Commit c46fd30

Browse files
Fix JS test cases failing because of latest version of @tanstack/react-virtual.
1 parent ff8a301 commit c46fd30

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

web/regression/javascript/setup-jest.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,7 @@ document.createRange = () => {
6666
return range;
6767
};
6868

69-
// for virtual tables, height should exist.
7069
Element.prototype.getBoundingClientRect = jest.fn(function () {
71-
if (this.classList?.contains('pgrt')) {
72-
return {
73-
width: 400,
74-
height: 400,
75-
top: 0,
76-
left: 0,
77-
bottom: 0,
78-
right: 0,
79-
x: 0,
80-
y: 0,
81-
toJSON: () => {},
82-
};
83-
}
8470
return {
8571
width: 0,
8672
height: 0,
@@ -94,6 +80,16 @@ Element.prototype.getBoundingClientRect = jest.fn(function () {
9480
};
9581
});
9682

83+
84+
// for virtual tables, height and width should exist.
85+
// https://github.com/TanStack/virtual/issues/641#issuecomment-2851908893
86+
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
87+
value: 800
88+
});
89+
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
90+
value: 800
91+
});
92+
9793
Object.defineProperty(global.SVGElement.prototype, 'getBBox', {
9894
writable: true,
9995
value: jest.fn().mockReturnValue({

0 commit comments

Comments
 (0)