Mock Node Modules

class MockModules { constructor() { this._resolvedPaths = {} } add({ path, mock }) { const resolvedPath = require.resolve(path) this._resolvedPaths[resolvedPath] = true require.cache[resolvedPath] = { id: resolvedPath, file: resolvedPath, loaded: true, »

React setState promise

Comes in handy _setStatePromise = state => { return new Promise(resolve => { this.setState(state, resolve) }) } use like so await this._setStatePromise({ key: value }) await doSomethingDependingOnThat() »