Last active
March 7, 2018 15:23
-
-
Save philipisapain/752d0a2e39abeb08a277160a5f97216c to your computer and use it in GitHub Desktop.
Testing a Node Process with a dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const proxyquire = require('proxyquire') | |
const SomeDependency = require('some-dependency') | |
describe('Stubbing a dependency passed to a constructor in a Node process', () => { | |
it('is not particularly elegant', () => { | |
const stubbedDependency = stub(new SomeDependency()) | |
const StubbedDependencyConstructor = () => stubbedDependency | |
proxyquire('./topLevelProcess', { 'some-dependency': StubbedDependencyConstructor }) | |
expect(/* something to have happened when `start()` is called */) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment