Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save philipisapain/752d0a2e39abeb08a277160a5f97216c to your computer and use it in GitHub Desktop.
Save philipisapain/752d0a2e39abeb08a277160a5f97216c to your computer and use it in GitHub Desktop.
Testing a Node Process with a dependency
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