Skip to content

Instantly share code, notes, and snippets.

@lennym
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennym/870e1a153fd8a72acccc to your computer and use it in GitHub Desktop.
Save lennym/870e1a153fd8a72acccc to your computer and use it in GitHub Desktop.
// example test script for module with http.get
// uses sinon, chai and mocha.
var Module = require('./my-module-that-does-http');
var http = require('http');
describe('Module', function () {
beforeEach(function () {
sinon.stub(http, 'get').yields(mockresponse);
});
afterEach(function () {
http.get.restore();
});
it('does an http.get', function () {
Module.foo();
http.get.should.have.been.called;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment