forked from graphql/graphiql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.config.js
50 lines (44 loc) · 1.13 KB
/
test.config.js
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
/* global jsdom */
/**
* Copyright (c) 2019 GraphQL Contributors.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
require('@babel/polyfill', {
rootMode: 'upward',
});
global.window = jsdom.window;
global.document = jsdom.window.document;
global.document.createRange = function() {
return {
setEnd() {},
setStart() {},
getClientRects() {
return { top: 0, bottom: 0, left: 0, right: 0 };
},
getBoundingClientRect() {
return { right: 0 };
},
};
};
// take all properties of the window object and also attach it to the
// mocha global object
propagateToGlobal(document.window);
// from mocha-jsdom
// https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80
function propagateToGlobal(window) {
for (const key in window) {
if (!window.hasOwnProperty(key)) {
continue;
}
if (key in global) {
continue;
}
global[key] = window[key];
}
}
process.on('unhandledRejection', error => {
console.error('Unhandled Promise Rejection:');
console.error((error && error.stack) || error);
});