Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const setupGlobalDom = () => {
- const originalDocument = global.document;
- const originalWindow = global.window;
- global.document = jsdom('');
- global.window = global.document.defaultView;
- return () => {
- global.document = originalDocument;
- global.window = originalWindow;
- }
- }
- const useGlobalDom = callback => {
- const teardownGlobalDom = setupGlobalDom();
- try {
- return callback();
- } finally {
- teardownGlobalDom();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement