You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
493 B
15 lines
493 B
import { jsdom } from 'jsdom';
|
|
|
|
module.exports = arg => {
|
|
const properties = arg instanceof Array ? arg : arg && arg.properties;
|
|
const overwrite = arg && arg.overwrite;
|
|
const window = jsdom('<html><body></body></html>').defaultView;
|
|
|
|
Object
|
|
.keys(window)
|
|
.filter(prop => typeof global[prop] === 'undefined' || properties && overwrite)
|
|
.filter(prop => !(properties && properties.indexOf(prop) === -1))
|
|
.forEach(prop => global[prop] = window[prop]);
|
|
|
|
return window;
|
|
};
|
|
|