Skip to content

Instantly share code, notes, and snippets.



Last active Sep 24, 2017
What would you like to do?
Poor Man's Dependency Injection
import dep1 from '../dep1';
import dep2 from '../dep2';
const defaultDeps = {
export function _myModuleFactory({ dep1, dep2 } = defaultDeps) {
const myModule = {};
// Module code here
return myModule;
export default _myModuleFactory();
import { _myModuleFactory } from './depInj.js';
const mockDep1;
const mockDep2;
const testableMyModule = _myModuleFactory({
dep1: mockDep1,
dep2: mockDep2,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.