2016-12-14 00:09:04 +02:00
|
|
|
const hook = require('node-hook');
|
2016-12-20 13:29:54 +02:00
|
|
|
const jsdom = require('jsdom');
|
2016-12-14 00:09:04 +02:00
|
|
|
const register = require('babel-register');
|
2017-01-25 14:18:42 +02:00
|
|
|
const requireHacker = require('require-hacker');
|
2016-12-14 00:09:04 +02:00
|
|
|
|
|
|
|
hook.hook('.png', () => '');
|
2017-01-13 20:10:09 +02:00
|
|
|
hook.hook('.eot', () => '');
|
|
|
|
hook.hook('.woff', () => '');
|
|
|
|
hook.hook('.woff2', () => '');
|
|
|
|
hook.hook('.ttf', () => '');
|
|
|
|
hook.hook('.svg', () => '');
|
2016-12-14 00:09:04 +02:00
|
|
|
|
|
|
|
register({
|
|
|
|
extensions: ['.js']
|
|
|
|
});
|
2016-12-20 13:29:54 +02:00
|
|
|
|
|
|
|
// import ExecutionEnvironment from 'react/lib/ExecutionEnvironment';
|
|
|
|
|
|
|
|
if (!global.document || !global.window) {
|
|
|
|
global.document = jsdom.jsdom('<!doctype html><html><body></body></html>');
|
|
|
|
global.window = global.document.defaultView;
|
|
|
|
global.navigator = global.window.navigator;
|
2017-01-13 20:10:09 +02:00
|
|
|
}
|
2017-01-25 14:18:42 +02:00
|
|
|
|
|
|
|
const fakeComponentString = `
|
|
|
|
require('react').createClass({
|
|
|
|
render() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
`;
|
|
|
|
|
|
|
|
// ensure inline svgs don't throw off testing
|
|
|
|
requireHacker.global_hook('inline-svgs', (path) => {
|
|
|
|
if(path.match(/!babel-loader!svg-react-loader/)) {
|
|
|
|
return `module.exports = ${fakeComponentString}`;
|
|
|
|
}
|
|
|
|
});
|