Skip to content

Instantly share code, notes, and snippets.

@EvidentlyCube EvidentlyCube/hookJsdom.js
Last active Apr 19, 2019

Embed
What would you like to do?
Hooking JSDom for PixiJS to run correctly in Mocha
/**
* Adapted from https://github.com/rstacruz/jsdom-global
* Make sure this file is registered when running tests by adding this to the command with which you run mocha:
* -r <path>/hookJsdom.js
*/
const JSDOM = require( 'jsdom' ).JSDOM;
const jsdomOptions = {
url: 'http://localhost/'
};
const jsdomInstance = new JSDOM( '', jsdomOptions );
const { window } = jsdomInstance;
Object.getOwnPropertyNames( window )
.filter( property => !property.startsWith( '_' ) )
.forEach( key => global[key] = window[key] );
global.window = window;
window.console = global.console;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.