-
Notifications
You must be signed in to change notification settings - Fork 629
Expand file tree
/
Copy pathjest.setup.js
More file actions
26 lines (23 loc) · 867 Bytes
/
jest.setup.js
File metadata and controls
26 lines (23 loc) · 867 Bytes
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
// Mimics ProvidePlugin configuration for jQuery
const jquery = require('jquery');
global.$ = jquery;
global.jQuery = jquery;
window.jQuery = jquery;
// Foundation requires existing script tag to load properly
document.getElementsByTagName('head')[0].appendChild(document.createElement('script'));
// jQuery thinks all elements are not visible under jsdom
// See https://github.com/jsdom/jsdom/issues/1048
window.Element.prototype.getClientRects = function () {
let node = this;
while (node) {
if (node === document) {
break;
}
// don't know why but style is sometimes undefined
if (!node.style || node.style.display === 'none' || node.style.visibility === 'hidden') {
return [];
}
node = node.parentNode;
}
return [{ width: this.offsetWidth, height: this.offsetHeight }];
};