I leave here the config urationthat AlbericoD posted earlier in text format, just in case for another dev need to copy it.
import Enzyme, { shallow, render, mount } from 'enzyme';
import toJson from 'enzyme-to-json';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
global.toJson = toJson;
global.shallow = shallow;
global.render = render;
global.mount = mount;
if(typeof windows.Twitch === 'undefined') {
Object.defineProperty(window, 'Twitch', {
value: {
ext: {
onAuthorized: jest.fn(),
listen: jest.fn(),
onContext: jest.fn(),
bits: {
getProducts: jest.fn(),
onTransactionCancelled: jest.fn(),
onTransactionComplete: jest.fn(),
setUseLoopback: jest.fn(),
showBitsBalance: jest.fn(),
useBits: jest.fn()
}
}
},
writable: true
})
}