Open Fen1kz opened 8 years ago
I have a problem in testing via mounting enzyme component. Problem line, for example (from extra/material.js):
if ('CustomEvent' in window && typeof window.CustomEvent === 'function') { ev = new CustomEvent('mdl-componentupgraded', {
This will fail in NodeJS, because CustomEvent is not defined in global scope, however window.CustomEvent is OK. Currently, I'm fixing this as doing
require('react-mdl/extra/material'); global.Element = global.window.Element; global.CustomEvent = global.window.CustomEvent; global.Event = global.window.Event; global.NodeList = global.window.NodeList; global.Node = global.window.Node;
However I don't feel this is right, it's preferable for me to not have this chunk of code at all, by changing problem line to
ev = new window.CustomEvent('mdl-componentupgraded', {
I believe you might be able to skip the use of react-mdl/extra-material inside a nodejs env. Have you tried it?
react-mdl/extra-material
I have a problem in testing via mounting enzyme component. Problem line, for example (from extra/material.js):
This will fail in NodeJS, because CustomEvent is not defined in global scope, however window.CustomEvent is OK. Currently, I'm fixing this as doing
However I don't feel this is right, it's preferable for me to not have this chunk of code at all, by changing problem line to