Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requestAnimationFrame from './tempPolyfills';
- import { configure } from 'enzyme';
- import Adapter from 'enzyme-adapter-react-16';
- configure({ adapter: new Adapter(), disableLifecycleMethods: true });
- const { JSDOM } = require('jsdom');
- const jsdom = new JSDOM(`
- <!doctype html>
- <html>
- <head>
- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<our maps key>&libraries=places"></script>
- <script>console.log(Window.google)</script>
- </head>
- <body>
- </body>
- </html>`, {runScripts: "dangerously"});
- const { window } = jsdom;
- function copyProps(src, target) {
- const props = Object.getOwnPropertyNames(src)
- .filter(prop => typeof target[prop] === 'undefined')
- .reduce((result, prop) => ({
- ...result,
- [prop]: Object.getOwnPropertyDescriptor(src, prop),
- }), {});
- Object.defineProperties(target, props);
- }
- global.window = window;
- global.document = window.document;
- global.navigator = {
- userAgent: 'node.js',
- };
- copyProps(window, global);
Add Comment
Please, Sign In to add comment