Skip to content

Instantly share code, notes, and snippets.

import { expect } from 'chai';
const proxyquire = require('proxyquire').noCallThru();
const requestsMock = { get: null };
const Tools = proxyquire('../Tools', {
'../../../utils/api/requests': requestsMock,
});
describe('Tools', () => {
let Tools;
let getMock;
describe('Tools', () => {
beforeEach(() => {
Tools = proxyquire('../Tools', {
'../../../utils/api/requests': { get: getMock },
});
});
// When getting error: "Cannot read property 'componentWillUnmount' of null"
// It's because React is swallowing the exception without rethrowing it
// In ReactCompositeComponent.js, edit lines that look like this, and add the Catch part
if (canInstantiate) {
if (process.env.NODE_ENV !== 'production') {
ReactCurrentOwner.current = this;
try {
inst = new Component(publicProps, publicContext, ReactUpdateQueue);
} catch (ex) {