Skip to content

Commit 634325c

Browse files
committed
maint(tests): Use global instead of window in node based tools like Jest for registering global variables.
1 parent 5f0f6ec commit 634325c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/setupTests.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import "core-js/stable";
99
import "regenerator-runtime/runtime";
1010

1111
import jquery from "jquery";
12-
window.jQuery = jquery;
12+
global["$"] = global["jQuery"] = jquery;
13+
1314
jquery.expr.pseudos.visible = function () {
1415
// Fix jQuery ":visible" selector always returns false in JSDOM.
1516
// https://github.com/jsdom/jsdom/issues/1048#issuecomment-401599392
@@ -26,10 +27,10 @@ document.fullscreenerror = jest.fn();
2627

2728
// pat-subform
2829
// See https://github.com/jsdom/jsdom/issues/1937#issuecomment-461810980
29-
window.HTMLFormElement.prototype.submit = () => {};
30+
global["HTMLFormElement"].prototype.submit = () => {};
3031

3132
// resize-observer
32-
window.ResizeObserver = function () {
33+
global["ResizeObserver"] = function () {
3334
// Just do nothing for now...
3435
return { observe: () => {} };
3536
};

0 commit comments

Comments
 (0)